-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
55 lines (52 loc) · 2.17 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
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const extractMainStyles = new ExtractTextPlugin('main.css');
const extractVendorStyles = new ExtractTextPlugin('vendor.css');
const bundleOutputDir = path.join(__dirname, './src/Golad/wwwroot/dist');
module.exports = (env) => {
const isDevBuild = !(env && env.config === 'Release');
const sourceMapsOrUglify = isDevBuild ?
new webpack.SourceMapDevToolPlugin({ filename: '[file].map' }) :
new webpack.optimize.UglifyJsPlugin()
return {
stats: { modules: false },
entry: {
main: path.join(__dirname, './src/Golad/ClientApp/index.jsx')
},
resolve: { extensions: [ '.js', '.jsx' ] },
output: {
path: bundleOutputDir,
filename: '[name].js',
publicPath: '/dist/'
},
module: {
rules: [
{ test: /\.(js|jsx)$/, include: /ClientApp/, use: 'babel-loader' },
{ test: /\.css$/, include: /ClientApp/, use: extractMainStyles.extract(['css-loader']) },
{ test: /\.(png|jpg|jpeg|gif|svg)$/, include: /ClientApp/, use: 'url-loader?limit=25000' },
{ test: /\.css(\?|$)/, include: /node_modules/, use: extractVendorStyles.extract(['css-loader']) },
{ test: /\.(png|woff|woff2|eot|ttf|svg)(\?|$)/, include: /node_modules/, use: 'url-loader?limit=100000' }
]
},
plugins: [
extractMainStyles,
extractVendorStyles,
sourceMapsOrUglify,
new webpack.DefinePlugin({
'process.env.NODE_ENV': isDevBuild ? '"development"' : '"production"'
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: (module) => (module.context || '').includes('node_modules')
}),
//CommonChunksPlugin will now extract all the common modules from vendor and main bundles.
new webpack.optimize.CommonsChunkPlugin({
// But since there are no more common modules between them
// we end up with just the runtime code included in the manifest file.
// This prevents hashes and other runtime stuff from being included into vendor chunk and changing it.
name: 'manifest'
})
]
};
};