编译配置存放于项目根目录下 config 目录中,包含三个文件
index.js是通用配置dev.js是项目预览时的配置prod.js是项目打包时的配置index.js —— 通用配置
const config = {// 项目名称projectName: 'kj',// 项目创建日期date: '2018-6-8',// 设计稿尺寸designWidth: 750,// 项目源码目录sourceRoot: 'src',// 项目产出目录outputRoot: 'dist',// babel 编译配置babel: {sourceMap: true,presets: ['env'],plugins: ['transform-class-properties', 'transform-decorators-legacy', 'transform-object-rest-spread']},// 编译插件配置plugins: [],// 全局变量设置defineConstants: {},// 文件 copy 配置copy: {patterns: [],options: {}},// 小程序端专用配置mini: {postcss: {autoprefixer: {enable: true},// 小程序端样式引用本地资源内联配置url: {enable: true,config: {limit: 10240}}},// 替换 JSX 中的属性名,参考:// https://github.com/NervJS/taro/issues/2077jsxAttributeNameReplace: {}},// H5 端专用配置h5: {publicPath: '/',staticDirectory: 'static',postcss: {autoprefixer: {enable: true}},// 自定义 Webpack 配置webpackChain: {},devServer: {}}};module.exports = function(merge) {if (process.env.NODE_ENV === 'development') {return merge({}, config, require('./dev'));}return merge({}, config, require('./prod'));};
