-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack-build.config.js
54 lines (46 loc) · 1.32 KB
/
webpack-build.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const webpack = require('webpack');
const path = require('path');
const CleanPlugin = require('clean-webpack-plugin');
const merge = require('webpack-merge');
const { version } = require('./package.json');
const srcDir = path.join(__dirname, './src');
const buildOutputDir = path.join(__dirname, './dist/');
const webpackCommon = require('./webpack-common.config.js');
const ExtractTextWebpackPlugin = require('extract-text-webpack-plugin');
const production = () => ({
context: srcDir,
entry: {
app: './index.js'
},
output: {
path: buildOutputDir,
filename: 'ccms-customer-view.js',
libraryTarget: "umd"
},
externals: ['angular', 'angular-resource', 'angular-ui-router', 'ccms-components'],
plugins: [
new CleanPlugin([buildOutputDir]),
// 将样式文件 抽取至独立文件内
new ExtractTextWebpackPlugin({
// 生成文件的文件名
filename: 'ccms-customer-view.css',
// 是否禁用插件
disable: false,
// 是否向所有额外的 chunk 提取(默认只提取初始加载模块)
allChunks: true
}),
// 配置环境变量
new webpack.DefinePlugin({
'process.env': {
VERSION: JSON.stringify(version)
}
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
minimize: true
})
]
});
module.exports = () => {
return merge(production(), webpackCommon);
};