-
Notifications
You must be signed in to change notification settings - Fork 15
/
webpack.config.js
74 lines (60 loc) · 1.64 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
var webpack = require('webpack')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var cssLoader = 'vue-style!css?sourceMap!postcss'
if (process.env.NODE_ENV === 'production') {
cssLoader = ExtractTextPlugin.extract('vue-style', 'css?-reduceTransforms!postcss')
}
var contentBase = __dirname + '/public'
var pkg = require('./package.json')
var plugins = [new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')
}
})]
var options = {
entry: {
app: [
'./app.js',
'./src/css/index.css'
],
},
output: {
path: contentBase + '/assets',
filename: 'app.js',
},
module: {
loaders: [
{test: /\.vue$/, loader: 'vue'},
{test: /\.css$/, loader: cssLoader},
]
},
vue: {
loaders: {
css: cssLoader,
}
},
postcss: function (pack) {
// use webpack context
return [
require('postcss-import')({path: './src/css', addDependencyTo: pack}),
require('postcss-css-variables'),
require('autoprefixer'),
]
},
devServer: {
contentBase: contentBase + '/_site',
publicPath: '/assets/',
host: '0.0.0.0',
},
plugins: plugins,
devtool: 'source-map',
}
if (process.env.NODE_ENV === 'production') {
options.entry.vendor = Object.keys(pkg.dependencies)
plugins.push(new ExtractTextPlugin('app.css', {disable: false}))
plugins.push(new webpack.optimize.CommonsChunkPlugin("vendor", "vendor.js"))
plugins.push(new webpack.optimize.UglifyJsPlugin({compress: {warnings: false}}))
plugins.push(new webpack.optimize.OccurenceOrderPlugin())
options.plugins = plugins
}
module.exports = options