編譯配置存放于項目根目錄下 config 目錄中,包含三個文件
const config = {
// 項目名稱
projectName: 'kj',
// 項目創(chuàng)建日期
date: '2018-6-8',
// 設計稿尺寸
designWidth: 750,
// 項目源碼目錄
sourceRoot: 'src',
// 項目產(chǎn)出目錄
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
},
// 小程序端樣式引用本地資源內(nèi)聯(lián)配置
url: {
enable: true,
config: {
limit: 10240
}
}
},
// 替換 JSX 中的屬性名,參考:
// https://github.com/NervJS/taro/issues/2077
jsxAttributeNameReplace: {}
},
// 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'));
};
更多建議: