-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
102 lines (87 loc) · 2.09 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
'use strict';
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const cssnext = require('postcss-cssnext');
const postcssNested = require('postcss-nested');
const postcssImport = require('postcss-import');
const config = require('c0nfig');
const isProduction = (config.env === 'production');
let plugins = [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify(config.env)
}
})
];
// extend plugins list for production
if (isProduction) {
plugins = plugins.concat([
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false },
output: { comments: false }
}),
new webpack.NoErrorsPlugin()
]);
}
// extract css into bundle file
plugins.push(
new ExtractTextPlugin(getFilename('css'))
);
module.exports = {
devtool: 'eval',
entry: {
common: './src/client/common.js',
home: './src/client/pages/home.js',
article: './src/client/pages/article.js'
},
output: {
path: path.join(__dirname, './public'),
filename: getFilename('js'),
publicPath: '/'
},
plugins: plugins,
resolve: {
extensions: ['', '.js', '.jsx', '.json', '.vue'],
alias: {
vue: 'vue/dist/vue.js'
}
},
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel'
}, {
test: /\.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css!postcss')
}, {
test: /\.(png|jpe?g|gif|eot|svg|ttf|woff|woff2)(\?\S*)?$/,
loaders: ['url?limit=10000', 'image-webpack?bypassOnDebug']
}, {
test: /\.vue$/,
loaders: ['vue']
}]
},
vue: {
loaders: {
js: 'babel'
}
},
postcss: function () {
return [postcssNested, postcssImport, cssnext];
},
imageWebpackLoader: {
gifsicle: {
interlaced: false
},
optipng: {
optimizationLevel: 7
}
}
};
function getFilename (ext) {
return isProduction ? `[name].min.${ext}` : `[name].${ext}`;
}