-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
97 lines (86 loc) · 2 KB
/
webpack.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
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
87
88
89
90
91
92
93
94
95
96
97
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ENV = process.env.npm_lifecycle_event;
const isDev = ENV === 'start';
const config = {
devtool: (isDev) ? 'eval' : 'source-map',
entry: {
app: './app/init.js',
vendor: './app/vendor.js'
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[chunkhash].app.js',
publicPath: '/'
},
module: {
rules: [
{
test: /\.html$/,
use: 'html-loader'
}, {
test: /\.(png|jpg|svg)$/,
use: 'file-loader?name=img/[name].[ext]'
}, {
test: /\.js$/,
exclude: /(node_modules)/,
use: ['babel-loader']
}, {
test: /\.css$/,
use: 'style-loader!css'
}, {
test: /\.scss$/,
use: ['style-loader', 'css-loader', 'postcss-loader', 'sass-loader']
}]
},
devServer: {
contentBase: 'dist/',
historyApiFallback: true,
compress: true,
clientLogLevel: 'info',
port: 8010,
inline: true,
filename: 'bundle.js',
publicPath: '/',
watchOptions: {
aggregateTimeout: 0,
poll: 500
},
stats: { colors: true }
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
include: /\.min\.js$/,
compressor: { warnings: false },
sourceMap: true,
compress: { drop_console: true },
minimize: true
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
filename: '[chunkhash].vendor.js',
minChunks: 'Infinity'
}),
new HtmlWebpackPlugin({
template: 'app/index.html'
}),
new webpack.LoaderOptionsPlugin({
test: /\.tpl.html$/, // may apply this only for some modules
options: {
htmlLoader: {
minimize: false
},
}
}),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': '"production"'
}
}),
],
resolve: {
modules: [ path.resolve(__dirname, 'app'), 'node_modules' ]
}
};
module.exports = config;