-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
71 lines (68 loc) · 1.63 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
var webpack = require('webpack');
var autoprefixer = require('autoprefixer');
var inlineSvg = require('postcss-inline-svg');
var svgo = require('postcss-svgo');
var path = require('path');
var OpenBrowserPlugin = require('open-browser-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var isProduction = process.argv.indexOf('--production') !== -1;
var config = {
entry: {
home: ['./src/js/home.js', 'webpack/hot/only-dev-server'],
detail: ['./src/js/detail.js', 'webpack/hot/only-dev-server'],
devServerClient: 'webpack-dev-server/client?http://localhost:3000'
},
output: {
path: path.join(__dirname, 'dist'),
filename: 'ws-[name].js',
publicPath: "/static/"
},
module: {
loaders: [
{
test: /\.scss/,
loader: 'style!css!postcss!sass'
},
{
test: /\.js/,
loader: 'babel',
include: /src/,
exclude: /node_modules/
}
]
},
sassLoader: {
sourceMap: true
},
postcss: [
inlineSvg(),
svgo(),
autoprefixer({
browsers: ['last 3 versions']
})
],
plugins: [
new HtmlWebpackPlugin({
inject: false,
chunks: ['home'],
filename: __dirname + '/src/template/home.html'
}),
new HtmlWebpackPlugin({
inject: false,
chunks: ['detail'],
filename: __dirname + '/src/template/detail.html'
}),
new webpack.HotModuleReplacementPlugin(),
]
}
if (isProduction) {
config.output.filename = 'ws-[name].min.js';
config.plugins = [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
]
}
module.exports = config;