-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
76 lines (70 loc) · 1.69 KB
/
webpack.config.js
File metadata and controls
76 lines (70 loc) · 1.69 KB
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
'use strict';
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const config = {
entry: './app/index.js',
module: {
rules: [
{
test: /(\.css|\.sass|\.scss)$/,
exclude: /node_modules/,
use: ['css-hot-loader'].concat(ExtractTextPlugin.extract({
use: [
{
loader: "style-loader" // creates style nodes from JS strings
},
{
loader: 'css-loader' // translates CSS into CommonJS
},
{
loader : 'sass-loader',
options: {
sourceMap: true
}
},
{
loader : 'postcss-loader',
options: {
plugins: function () {
return [
require("autoprefixer")
];
}
}
}
]
})),
},
{
test: /\.(js)$/,
exclude: /(node_modules|bower_components)/,
use : ['babel-loader']
}
]
},
devtool: 'source-map',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
// publicPath: '/' // avoid requesting server route instead of client route when hitting refresh /Cannot GET /route
},
plugins : [
new HtmlWebpackPlugin({
template: 'app/index.html'
}),
new ExtractTextPlugin({ filename: 'css/style.css', disable: true, allChunks: true }), // this means dist/css/style.css
]
};
if(process.env.NODE_ENV === "production"){ // 'production ready'
config.plugins.push(
new webpack.DefinePlugin({
'process.env' : {
'NODE_ENV' : JSON.stringify(process.env.NODE_ENV)
}
}),
new webpack.optimize.UglifyJsPlugin({ sourceMap: true, minimize: true })
)
}
module.exports = config;