1 | const webpack = require('webpack');
|
2 | const path = require('path');
|
3 |
|
4 | process.env.NODE_ENV = 'production';
|
5 |
|
6 | module.exports = {
|
7 | entry: {
|
8 | main: './src/component/button/index.js',
|
9 | vendor: ['react', 'react-dom']
|
10 | },
|
11 | output: {
|
12 | filename: '[name].[chunkhash].js',
|
13 | path: path.resolve(__dirname, 'build')
|
14 | },
|
15 | plugins: [
|
16 | new webpack.DefinePlugin({
|
17 | 'process.env': {
|
18 | NODE_ENV: JSON.stringify('production2')
|
19 | }
|
20 | }),
|
21 | new webpack.optimize.CommonsChunkPlugin({
|
22 | name: 'vendor',
|
23 | minChunks: Infinity,
|
24 | filename: 'vendor.min.js'
|
25 | }),
|
26 | new webpack.optimize.UglifyJsPlugin({
|
27 | compress: {
|
28 | warnings: false,
|
29 | screw_ie8: true,
|
30 | conditionals: true,
|
31 | unused: true,
|
32 | comparisons: true,
|
33 | sequences: true,
|
34 | dead_code: true,
|
35 | evaluate: true,
|
36 | if_return: true,
|
37 | join_vars: true,
|
38 | },
|
39 | output: {
|
40 | comments: false,
|
41 | },
|
42 | })
|
43 | ],
|
44 | module: {
|
45 | rules: [{
|
46 | test: /\.(js|jsx)$/,
|
47 | exclude: /node_modules/,
|
48 | use: [
|
49 | 'babel-loader'
|
50 | ]
|
51 | }, {
|
52 | test: /\.css$/,
|
53 | exclude: /node_modules/,
|
54 | use: [
|
55 | 'style-loader',
|
56 | 'css-loader'
|
57 | ]
|
58 | }, {
|
59 | test: /(\.jp(e)g|\.png|\.gif|\.svg)$/,
|
60 | exclude: /node_modules/,
|
61 | use: {
|
62 | loader: 'file-loader',
|
63 | query: {
|
64 | name: '[name].[ext]'
|
65 | },
|
66 | }
|
67 | }]
|
68 | }
|
69 | };
|