feat(cli): support custom webpack config

This commit is contained in:
陈嘉涵
2019-11-22 14:32:27 +08:00
parent 578448d040
commit 287251fa90
5 changed files with 121 additions and 87 deletions
+32 -27
View File
@@ -1,6 +1,7 @@
import { join } from 'path';
import merge from 'webpack-merge';
import { join } from 'path';
import { baseConfig } from './webpack.base';
import { getWebpackConfig } from '../common';
import { LIB_DIR, DIST_DIR, CONFIG_FILE } from '../common/constant';
// eslint-disable-next-line
@@ -8,32 +9,36 @@ const config = require(CONFIG_FILE);
const { name } = config;
export function packageConfig(isMinify: boolean) {
return merge(baseConfig as any, {
mode: 'production',
entry: {
[name]: join(DIST_DIR, 'index.js')
},
stats: 'none',
output: {
path: LIB_DIR,
library: name,
libraryTarget: 'umd',
filename: isMinify ? '[name].min.js' : '[name].js',
umdNamedDefine: true,
// https://github.com/webpack/webpack/issues/6522
globalObject: "typeof self !== 'undefined' ? self : this"
},
externals: {
vue: {
root: 'Vue',
commonjs: 'vue',
commonjs2: 'vue',
amd: 'vue'
return merge(
baseConfig as any,
{
mode: 'production',
entry: {
[name]: join(DIST_DIR, 'index.js')
},
stats: 'none',
output: {
path: LIB_DIR,
library: name,
libraryTarget: 'umd',
filename: isMinify ? '[name].min.js' : '[name].js',
umdNamedDefine: true,
// https://github.com/webpack/webpack/issues/6522
globalObject: "typeof self !== 'undefined' ? self : this"
},
externals: {
vue: {
root: 'Vue',
commonjs: 'vue',
commonjs2: 'vue',
amd: 'vue'
}
},
performance: false,
optimization: {
minimize: isMinify
}
},
performance: false,
optimization: {
minimize: isMinify
}
});
getWebpackConfig()
);
}