-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.build.js
86 lines (79 loc) · 2.05 KB
/
webpack.build.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
var rules = require("./rules");
var HtmlWebpackPlugin = require('html-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var CleanWebpackPlugin = require('clean-webpack-plugin');
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
var webpack = require('webpack');
var path = require('path');
module.exports = {
entry: [
'./src/index'
],
output: {
filename: '[name]_[chunkhash].js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/'
},
resolve: {
modules: [
'node_modules',
path.resolve(__dirname, 'src')
],
extensions: ['.ts', '.tsx', '.js', '.sass', '.scss', '.html']
},
devtool: "cheap-module-source-map",
plugins: [
//new BundleAnalyzerPlugin({
// analyzerMode: 'static'
//}),
new webpack.optimize.UglifyJsPlugin(
{
warning: false,
mangle: true,
comments: false
}
),
new HtmlWebpackPlugin({
template: './index.html',
inject: 'body'
//hash: true
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks(module, count) {
var context = module.context;
return context && context.indexOf('node_modules') >= 0;
}
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest'
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
'window.jquery': 'jquery'
}),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new webpack.DefinePlugin({
"process.env": {
"NODE_ENV": JSON.stringify("production")
}
}),
new CopyWebpackPlugin([
// {output}/file.txt
//{ from: 'src/assets', to: 'src/assets' },
//{ from: 'favicon.ico', to: 'favicon.ico' },
//{ from: 'statics/_redirects', to: './' },
//{ from: 'statics/robots.txt', to: 'robots.txt' },
]),
new CleanWebpackPlugin(['dist'], {
root: __dirname,
verbose: true,
dry: false
})
],
module: {
rules: rules
}
};