-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.prod.js
63 lines (61 loc) · 1.7 KB
/
webpack.config.prod.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
const CleanWebpackPlugin = require('clean-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const path = require('path')
const webpack = require('webpack')
// Define two different css extractors
const extractBundle = new ExtractTextPlugin('[name]-[hash].css')
const extractVendor = new ExtractTextPlugin('vendor-[hash].css')
module.exports = {
entry: {
main: [
path.join(__dirname, './src/client/index')
]
},
output: {
path: path.join(__dirname, 'dist', 'public'),
filename: '[name]-[chunkhash].js',
chunkFilename: '[name].[chunkhash].js'
},
resolve: {
extensions: ['.js', '.jsx'],
modules: ['node_modules']
},
module: {
rules: [
{
test: /\.js$|\.jsx$/,
exclude: /node_modules\/(?!(map-obj|camelcase)\/).*/,
loader: 'babel-loader'
},
{
test: /\.css$/,
include: /node_modules/,
loader: extractVendor.extract({
fallback: 'style-loader?sourceMap',
use: 'css-loader?sourceMap'
})
},
{
test: /\.css$/,
exclude: /node_modules/,
loader: extractBundle.extract({
fallback: 'style-loader?sourceMap',
use: 'css-loader?sourceMap'
})
}
]
},
devtool: 'source-map',
plugins: [
extractVendor,
extractBundle,
new CleanWebpackPlugin(path.join(__dirname, 'dist', 'public'), { verbose: false }),
new webpack.optimize.UglifyJsPlugin({ sourceMap: true }),
new webpack.EnvironmentPlugin([
'NODE_ENV',
'API'
]),
new HtmlWebpackPlugin({ template: path.join(__dirname, 'src', 'client', 'index.ejs') })
]
}