forked from wbkd/webpack-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.prod.js
44 lines (42 loc) · 1.08 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
'use strict';
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
const Webpack = require('webpack');
const Path = require('path');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const ExtractSASS = new ExtractTextPlugin('styles/bundle.css');
module.exports = merge(common, {
mode: 'production',
devtool: 'source-map',
stats: 'errors-only',
optimization: {
minimize: true
},
plugins: [
new Webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new ExtractTextPlugin({ filename: 'bundle.css' }),
// compiling mode “scope hoisting”
new Webpack.optimize.ModuleConcatenationPlugin(),
ExtractSASS
],
resolve: {
alias: {
'~': Path.resolve(__dirname, '../src')
}
},
module: {
rules: [
{
test: /\.(js)$/,
exclude: /(node_modules|bower_components)/,
use: 'babel-loader'
},
{
test: /\.s?css/i,
use: ExtractSASS.extract(['css-loader?sourceMap=true&minimize=true', 'sass-loader'])
}
]
}
});