-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
63 lines (61 loc) · 1.79 KB
/
vue.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
const VueSSRServerPlugin = require("vue-server-renderer/server-plugin");
const VueSSRClientPlugin = require("vue-server-renderer/client-plugin");
const nodeExternals = require("webpack-node-externals");
const merge = require("lodash.merge");
const path = require("path");
const TARGET_NODE = process.env.WEBPACK_TARGET === "node";
const target = TARGET_NODE ? "server" : "client";
module.exports = {
publicPath: "/dist",
filenameHashing: false,
css: {
extract: process.env.NODE_ENV === "production",
loaderOptions: {
sass: {}
}
},
devServer: {
proxy: {
"/api": {
target: "<https://localhost:5001>",
changeOrigin: true
}
}
},
configureWebpack: () => ({
entry: `./ClientApp/entry-${target}`,
target: TARGET_NODE ? "node" : "web",
// For bundle renderer source map support
devtool: TARGET_NODE ? "source-map" : undefined,
node: TARGET_NODE ? undefined : false,
plugins: [
TARGET_NODE ? new VueSSRServerPlugin() : new VueSSRClientPlugin()
],
// <https://webpack.js.org/configuration/externals/#function>
// <https://github.com/liady/webpack-node-externals>
// Externalize app dependencies. This makes the server build much faster
// and generates a smaller bundle file.
externals: TARGET_NODE
? nodeExternals({
whitelist: /\\.css$/
})
: undefined,
output: {
libraryTarget: TARGET_NODE ? "commonjs2" : undefined
},
optimization: {
splitChunks: TARGET_NODE ? { chunks: "all" } : undefined
}
}),
chainWebpack: config => {
config.module
.rule("vue")
.use("vue-loader")
.tap(options =>
merge(options, {
optimizeSSR: false
})
);
config.resolve.alias.set("@", path.join(__dirname, "./ClientApp"));
}
};