forked from js-gang/module-two-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
61 lines (57 loc) · 1.23 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
var path = require('path')
var appPath = path.join(__dirname, 'src')
var webpack = require('webpack')
var HtmlWebackPlugin = require('html-webpack-plugin')
var CleanWebpackPlugin = require('clean-webpack-plugin');
var env = process.env.NODE_ENV
var debug = env !== 'production'
var minify = !debug
var plugins = [
new HtmlWebackPlugin({
filename: 'index.html',
template: path.join(appPath, 'index.html'),
minify: false
}),
new CleanWebpackPlugin(['dist'], {
root: appPath,
verbose: true,
})
]
if(minify){
plugins.push(new webpack.optimize.UglifyJsPlugin())
}
module.exports = {
entry: {// configurationocal
bundle: './src/main.js'
},
output: {
path: './src/dist',
filename: '[hash]_[name].js'
},
devtool: "inline-source-map",
debug: debug,
devServer: {
host: 'localhost',
port: 8080
},
module: {
loaders: [
{
test: /\.js/,
loader: "babel"
},
{
test: /\.css/,
loaders: ['style', 'css']
},
{
test: /\.(gif|png|jpe?g)/,
loader: 'file',
query:{
name: '[path][name].[ext]?[hash]'
}
}
]
},
plugins: plugins
};