-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathwebpack.config.js
More file actions
111 lines (105 loc) · 2.41 KB
/
webpack.config.js
File metadata and controls
111 lines (105 loc) · 2.41 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
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
103
104
105
106
107
108
109
110
111
/**
* Webpack client-side config file
*/
const path = require( 'path' );
const webpack = require( 'webpack' );
const ExtractTextPlugin = require( 'extract-text-webpack-plugin' );
const config = require( './common/config' );
// server details
const devServer = config.devServer;
const mainServer = config.mainServer;
// global stuff
const cssVars = './client/scss/globals';
const isProd = ( process.env.NODE_ENV === 'production' );
// hot reload vue css in development
const vueDevLoaders = {
scss: 'vue-style-loader!css-loader!postcss-loader!sass-loader?data=@import "'+ cssVars +'";'
}
// extract vue css in production build
const vueProdLoaders = {
scss: ExtractTextPlugin.extract({
use: 'css-loader!postcss-loader!sass-loader?data=@import "'+ cssVars +'";',
fallback: 'vue-style-loader'
})
}
module.exports = {
devtool: '#eval-source-map',
entry: {
app: './client/main.js',
},
output: {
path: mainServer.public,
publicPath: '/',
filename: 'dist/[name].bundle.js',
},
module: {
rules: [
{
test: /\.(jpe?g|png|gif|svg|map|css|eot|woff|woff2|ttf)$/,
loader: 'ignore-loader',
},
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: isProd ? vueProdLoaders : vueDevLoaders
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
}
]
},
plugins: [
new ExtractTextPlugin( 'dist/[name].bundle.css' )
],
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
}
},
devServer: {
host: devServer.host,
port: devServer.port,
contentBase: mainServer.public,
clientLogLevel: 'info',
historyApiFallback: {
index: devServer.fallback,
},
proxy: {
'/': {
target: 'http://'+ mainServer.host +':'+ mainServer.port +'/',
secure: false,
}
},
hot: true,
inline: true,
quiet: false,
noInfo: false,
compress: false,
},
performance: {
hints: false
}
}
if ( isProd ) {
module.exports.devtool = '#source-map'
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
])
}