-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
95 lines (77 loc) · 2.14 KB
/
webpack.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
83
84
85
86
87
88
89
90
91
92
93
94
95
const path = require("path")
const { DefinePlugin } = require("webpack")
const CopyPlugin = require("copy-webpack-plugin")
const { VueLoaderPlugin } = require("vue-loader")
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin")
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin")
const static_folder = path.resolve(__dirname, "static")
const pkg_folder = path.resolve(__dirname, "pkg")
const dist_folder = path.resolve(__dirname, "dist")
const envDefaults = {
prod: false,
}
module.exports = (env = envDefaults) => ({
mode: env.prod === true ? "production" : "development",
devtool: env.prod === true ? "source-map" : "eval-cheap-module-source-map",
entry: path.resolve(__dirname, "./js/main.ts"),
experiments: { syncWebAssembly: true },
output: {
path: dist_folder,
},
resolve: {
extensions: [".ts", ".js", ".vue", ".json"],
alias: {
vue: "@vue/runtime-dom",
},
plugins: [new TsconfigPathsPlugin()],
},
module: {
rules: [
{
test: /\.ts$/,
use: [
"babel-loader",
{
loader: "ts-loader",
options: {
appendTsSuffixTo: [/\.vue$/],
},
},
],
},
{
test: /\.vue$/,
use: "vue-loader",
},
{ test: /\.css$/, use: ["vue-style-loader", "css-loader"] },
],
},
plugins: [
new CopyPlugin({
patterns: [{ from: static_folder, to: dist_folder }],
}),
new VueLoaderPlugin(),
new WasmPackPlugin({
crateDirectory: __dirname,
}),
// needed for wasm-pack because bugs
new DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify(env.prod === true ? "production" : "development"),
},
__VUE_OPTIONS_API__: JSON.stringify(false),
__VUE_PROD_DEVTOOLS__: JSON.stringify(env.prod !== false),
}),
],
watchOptions: {
aggregateTimeout: 200,
poll: 200,
},
devServer: {
// static: './dist'
// static: { directory: dist_folder, watch: true },
// static: { directory: pkg_folder, watch: true },
// static: { directory: static_folder, watch: true },
// hot: true,
},
})