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