webpack.client.conf.js
1.53 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
const webpack = require('webpack');
const path = require('path');
const merge = require('webpack-merge');
const VueSSRClientPlugin = require('vue-server-renderer/client-plugin');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const shelljs = require('shelljs');
let baseConfig = require('./webpack.base.conf');
shelljs.exec(`cp -R ${path.join(__dirname, '../public/font/')} ${path.join(__dirname, '../src/statics')}`, {async: true});
shelljs.exec(`cp -R ${path.join(__dirname, '../public/img/')} ${path.join(__dirname, '../src/statics')}`, {async: true});
const webpackConfig = merge(baseConfig, {
entry: {
app: './src/entry-client.js'
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
'process.env.VUE_ENV': '"client"'
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: function(module) {
return (
/node_modules/.test(module.context) &&
!/\.css$/.test(module.request)
);
}
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
}),
new VueSSRClientPlugin()
]
});
if (process.env.NODE_ENV === 'production') {
webpackConfig.plugins.push(new UglifyJSPlugin({
parallel: true,
sourceMap: true
}));
webpackConfig.output.publicPath = '//cdn.yoho.cn/yohoblk-wap/';
}
module.exports = webpackConfig;