-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
69 lines (66 loc) · 1.61 KB
/
webpack.config.js
File metadata and controls
69 lines (66 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
68
69
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const merge = require('webpack-merge');
const pug = require('./webpack/pug');
const devserver = require('./webpack/devserver');
const sass = require('./webpack/sass');
const css = require('./webpack/css');
const extractCSS = require('./webpack/css.extract');
const uglifyJS = require('./webpack/js.uglify');
const images = require('./webpack/images');
const PATHS = {
source: path.join(__dirname, 'source'),
build: path.join(__dirname, 'build')
};
const common = merge ([
{
entry: {
'index': PATHS.source + '/pages/index/index.js',
'blog': PATHS.source + '/pages/blog/blog.js'
},
output: {
path: PATHS.build,
filename: 'js/ [name].js'
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
chunks: ['index', 'common'],
template: PATHS.source + '/pages/index/index.pug'
}),
new HtmlWebpackPlugin({
filename: 'blog.html',
chunks: ['blog', 'common'],
template: PATHS.source + '/pages/blog/blog.pug'
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'common'
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
})
]
},
pug(),
images()
]);
module.exports = function(env) {
"use strict";
if (env === 'production') {
return merge([
common,
extractCSS(),
uglifyJS()
])
}
if (env === 'development') {
return merge([
common,
devserver(),
sass(),
css()
])
}
};