-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
47 lines (41 loc) · 1.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
const path = require("path");
const webpack = require("webpack");
function checkEnv(value, allowedValues, name) {
if (!allowedValues.includes(value)) {
throw new Error(`unrecognized ${name}`);
}
}
module.exports = function config(env) {
checkEnv(env.mode, ["development", "production"], "env.mode");
checkEnv(env.out, ["dist", "demo"], "env.out");
checkEnv(env.appType, ["survey", "decision-tree"], "env.appType");
const vueCdnUrl = {
development: "https://unpkg.com/vue@3.2.8/dist/vue.global.js",
production: "https://unpkg.com/vue@3.2.8/dist/vue.global.prod.js",
}[env.mode];
const outDir = {
demo: path.resolve(__dirname, `demo/${env.appType}/dist`),
dist: path.resolve(__dirname, "dist"),
}[env.out];
return {
mode: env.mode,
entry: `./src/${env.appType}/main.js`,
output: {
filename: `auma-${env.appType}.js`,
path: outDir,
},
module: {
rules: [
{
test: /\.css$/i,
use: ["style-loader", "css-loader"],
},
],
},
plugins: [
new webpack.DefinePlugin({
VUE_CDN_URL: JSON.stringify(vueCdnUrl),
}),
],
};
};