forked from survivejs-demos/webpack-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
79 lines (74 loc) · 1.73 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const merge = require('webpack-merge');
const parts = require('./webpack.parts');
const PATHS = {
app: path.join(__dirname, 'app'),
style: [
path.join(__dirname, 'node_modules', 'purecss'),
path.join(__dirname, 'app', 'main.css')
],
build: path.join(__dirname, 'build')
};
const common = {
entry: {
style: PATHS.style,
app: PATHS.app
},
output: {
path: PATHS.build,
filename: '[name].js'
},
plugins: [
new HtmlWebpackPlugin({
title: 'Webpack demo'
})
]
};
module.exports = function(env) {
if (env === 'build') {
return merge(
common,
{
devtool: 'source-map',
output: {
path: PATHS.build,
filename: '[name].[chunkhash].js',
// This is used for code splitting. The setup
// will work without but this is useful to set.
chunkFilename: '[chunkhash].js',
// Tweak this to match your GitHub project name
publicPath: '/webpack-demo/'
}
},
parts.clean(PATHS.build),
parts.setFreeVariable(
'process.env.NODE_ENV',
'production'
),
parts.extractBundle({
name: 'vendor',
entries: ['react']
}),
parts.minify(),
parts.extractCSS(PATHS.style),
parts.purifyCSS([PATHS.app])
);
}
return merge(
common,
{
devtool: 'eval-source-map',
// Disable performance hints during development
performance: {
hints: false
}
},
parts.setupCSS(PATHS.style),
parts.devServer({
// Customize host/port here if needed
host: process.env.HOST,
port: process.env.PORT
})
);
};