-
Notifications
You must be signed in to change notification settings - Fork 16
/
webpack.prd.js
42 lines (39 loc) · 1022 Bytes
/
webpack.prd.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
const path = require('path');
const webpack = require('webpack');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const NODE_ENV = process.env.NODE_ENV;
const prdWebpackConfig= {
mode: 'production',
entry: path.resolve(__dirname, 'src/index.js'),
output: {
path: path.join(__dirname, 'lib'),
filename: "chat-react.js",
libraryTarget: 'commonjs2' //模块输出方式
},
externals: {
react: 'react' //打包时候排除react
},
module: {
rules: [
{
test: /(\.jsx|\.js)$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{test: /\.css$/, loader: 'style-loader!css-loader'},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'url-loader',
options: {
limit: 8192,
name: '[name].[ext]?[hash]'
}
}
]
},
plugins: []
};
if (NODE_ENV !== 'publish') {
prdWebpackConfig.plugins.push(new BundleAnalyzerPlugin())
}
module.exports = prdWebpackConfig;