-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvue.config.js
82 lines (78 loc) · 2.06 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
const { defineConfig } = require("@vue/cli-service");
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
const dist = path.resolve(__dirname, "dist");
function resolve(dir) {
return path.join(__dirname, dir);
}
module.exports = defineConfig({
transpileDependencies: ["mbti-worker", "mbti-data"],
configureWebpack: {
entry: {
app: "./src/main.ts",
"mbti.worker": "./worker/mbti.worker.ts",
"data/mbti.data": "./worker/data/mbti.data.ts",
},
output: {
path: dist,
filename: "[name].js",
},
resolve: {
alias: {
"@": resolve("src"),
"@worker": resolve("worker"),
"@data": resolve("worker/data"),
},
},
optimization: {
runtimeChunk: "single",
splitChunks: {
chunks: "async",
minSize: 30000,
minChunks: 1,
maxAsyncRequests: 5,
maxInitialRequests: 3,
name: (chunk) =>
chunk.name in ["app", "mbti.worker", "data/mbti.data"]
? chunk.name
: "chunk",
cacheGroups: {
default: {
minChunks: 2,
priority: -20,
reuseExistingChunk: true,
},
vendors: {
test: /[\\/]node_modules[\\/]/,
priority: -10,
},
},
},
},
plugins: [
new CopyPlugin({
patterns: [
{
from: "worker/data/mbti_samples.json",
to: "data/mbti_samples.json",
},
{ from: "worker/data/network.json", to: "data/network.json" },
{ from: "worker/pkg", to: "js/pkg" },
],
}),
new WasmPackPlugin({
crateDirectory: __dirname,
extraArgs: "--target no-modules", // our wasm is used in a Web Worker not as an ES6 module
outName: "mbti_wasm",
outDir: "worker/pkg",
}),
],
},
chainWebpack: (config) => {
config.plugin("html").tap((args) => {
args[0].inject = false;
return args;
});
},
});