-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.scripts.config.js
62 lines (56 loc) · 1.67 KB
/
webpack.scripts.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
const webpack = require("webpack");
const path = require("path");
const { ON_SERVICE_VERSIONS, CURRENT_VERSION } = require("./src/constants");
const DIST_DIR = path.resolve(__dirname, "src/public/js");
const SRC_DIR = path.resolve(__dirname, "src");
var createScriptsConfig = (version, flag) => ({
mode: "production",
entry: {
uploaddata_latest: `${SRC_DIR}/scripts/uploaddata_template.js`
},
output: {
path: DIST_DIR,
filename: flag
? `uploaddata_${version}_${flag}.js`
: `uploaddata_${version}.js`
},
module: {
rules: [
{
test: /\.jsx?$/,
use: [
{
loader: "babel-loader"
}
],
include: SRC_DIR
}
]
},
plugins: [
new webpack.DefinePlugin({
"process.env.TARGET_DOMAIN":
flag === "local"
? '"http://127.0.0.1:5000"'
: flag === "dev"
? '"//gitadora-skill-viewer-dev.herokuapp.com"'
: '"http://gsv.fun"',
"process.env.SCRIPT_DOMAIN":
flag === "local"
? '"http://127.0.0.1:5000"'
: '"//gitadora-skill-viewer.herokuapp.com"',
"process.env.VERSION":
version === "latest" ? `"${CURRENT_VERSION}"` : `"${version}"`
})
]
});
let moduleExports = [];
moduleExports.push(createScriptsConfig("latest"));
moduleExports.push(createScriptsConfig("latest", "dev"));
moduleExports.push(createScriptsConfig("latest", "local"));
ON_SERVICE_VERSIONS.slice(1).forEach(version => {
moduleExports.push(createScriptsConfig(version));
moduleExports.push(createScriptsConfig(version, "dev"));
moduleExports.push(createScriptsConfig(version, "local"));
});
module.exports = moduleExports;