-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathwebpack.config.js
More file actions
67 lines (61 loc) · 1.61 KB
/
webpack.config.js
File metadata and controls
67 lines (61 loc) · 1.61 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
const { join } = require('path')
const Webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const WriteFilePlugin = require('write-file-webpack-plugin')
const paths = require('./src/config/paths')
const __DEV__ = process.env.NODE_ENV !== 'production'
const __PROD__ = process.env.NODE_ENV === 'production'
const config = {
entry: {
immediate: join(paths.webpackSource, 'js', 'immediate.js'),
page: join(paths.webpackSource, 'js', 'page.js')
},
devtool: __DEV__ ? '#cheap-module-eval-source-map' : false,
output: {
path: paths.webpackDestination,
publicPath: paths.webpackPublicPath,
filename: '[name].js'
},
module: {
rules: [
{
test: /\.js$/,
use: 'babel-loader'
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
use: ['css-loader', 'postcss-loader']
})
}
]
},
plugins: [
new ExtractTextPlugin({
filename: 'page.css',
allChunks: true
})
]
}
if (__DEV__) {
config.plugins.push(new Webpack.LoaderOptionsPlugin({
debug: true
}))
// Force webpack-dev-middleware to write files to the disk for metalsmith
config.plugins.push(new WriteFilePlugin({
log: false
}))
}
if (__PROD__) {
config.plugins.push(new Webpack.LoaderOptionsPlugin({
minimize: true
}))
config.plugins.push(new Webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}))
config.plugins.push(new Webpack.optimize.AggressiveMergingPlugin())
config.plugins.push(new Webpack.optimize.UglifyJsPlugin())
}
module.exports = config