mirror of
https://github.com/youzan/vant.git
synced 2025-10-16 08:00:34 +00:00
simplify build config (#638)
This commit is contained in:
@@ -1,50 +1,29 @@
|
||||
const webpack = require('webpack');
|
||||
const config = require('./webpack.config.dev.js');
|
||||
const isMinify = process.argv.indexOf('-p') !== -1;
|
||||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
||||
const isMinify = process.argv.indexOf('-p') !== -1;
|
||||
|
||||
config.entry = {
|
||||
'vant': './packages/index.js'
|
||||
};
|
||||
|
||||
config.output = {
|
||||
filename: isMinify ? './lib/[name].min.js' : './lib/[name].js',
|
||||
library: 'vant',
|
||||
libraryTarget: 'umd',
|
||||
umdNamedDefine: true
|
||||
};
|
||||
|
||||
config.externals = {
|
||||
vue: {
|
||||
root: 'Vue',
|
||||
commonjs: 'vue',
|
||||
commonjs2: 'vue',
|
||||
amd: 'vue'
|
||||
}
|
||||
};
|
||||
|
||||
config.plugins = [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.NODE_ENV': '"production"'
|
||||
}),
|
||||
new webpack.LoaderOptionsPlugin({
|
||||
minimize: true,
|
||||
debug: false,
|
||||
options: {
|
||||
vue: {
|
||||
autoprefixer: false,
|
||||
preserveWhitespace: false
|
||||
}
|
||||
module.exports = Object.assign({}, config, {
|
||||
entry: {
|
||||
'vant': './packages/index.js'
|
||||
},
|
||||
output: {
|
||||
filename: isMinify ? './lib/[name].min.js' : './lib/[name].js',
|
||||
library: 'vant',
|
||||
libraryTarget: 'umd',
|
||||
umdNamedDefine: true
|
||||
},
|
||||
externals: {
|
||||
vue: {
|
||||
root: 'Vue',
|
||||
commonjs: 'vue',
|
||||
commonjs2: 'vue',
|
||||
amd: 'vue'
|
||||
}
|
||||
}),
|
||||
new webpack.optimize.ModuleConcatenationPlugin()
|
||||
];
|
||||
|
||||
// analyze bundle size if need
|
||||
// if (isMinify) {
|
||||
// config.plugins.push(new BundleAnalyzerPlugin());
|
||||
// }
|
||||
|
||||
delete config.devtool;
|
||||
|
||||
module.exports = config;
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.NODE_ENV': '"production"'
|
||||
}),
|
||||
new webpack.optimize.ModuleConcatenationPlugin()
|
||||
]
|
||||
});
|
||||
|
Reference in New Issue
Block a user