-
Notifications
You must be signed in to change notification settings - Fork 30
/
webpack.client.js
70 lines (65 loc) · 1.64 KB
/
webpack.client.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
const webpack = require('webpack');
const merge = require('webpack-merge');
const VueSSRClientPlugin = require('vue-server-renderer/client-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');
const baseConfig = require('./webpack.base.js');
const isProduction = process.env.NODE_ENV === 'production';
let config = merge(baseConfig, {
entry: ['./app/entry-client.js'],
plugins: [new VueSSRClientPlugin()],
output: {
path: path.resolve('./dist/'),
filename: '[name].[hash:8].js',
publicPath: '/dist/',
},
module: {
rules: [
{
test: /\.css$/,
use: [
isProduction ? MiniCssExtractPlugin.loader : 'vue-style-loader',
{
loader: 'css-loader',
options: {
modules: {
localIdentName: '[local]_[hash:base64:8]',
},
},
},
],
},
],
},
});
if (!isProduction) {
config = merge(config, {
output: {
filename: '[name].js',
publicPath: 'http://localhost:9999/dist/',
},
plugins: [new webpack.HotModuleReplacementPlugin()],
devtool: 'source-map',
devServer: {
writeToDisk: true,
contentBase: path.resolve(__dirname, 'dist'),
publicPath: 'http://localhost:9999/dist/',
hot: true,
inline: true,
historyApiFallback: true,
port: 9999,
headers: {
'Access-Control-Allow-Origin': '*',
},
},
});
} else {
config = merge(config, {
plugins: [
new MiniCssExtractPlugin({
filename: '[name].[hash:8].css',
}),
],
});
}
module.exports = config;