2020-05-11 19:37:57 +00:00
|
|
|
/* eslint-env node */
|
|
|
|
|
2020-05-12 22:24:41 +00:00
|
|
|
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
|
2019-05-08 18:27:07 +00:00
|
|
|
const CopyWebpackPlugin = require("copy-webpack-plugin");
|
2020-11-04 22:27:55 +00:00
|
|
|
const webpack = require("webpack");
|
2020-05-12 22:24:41 +00:00
|
|
|
const path = require("path");
|
2019-05-08 18:27:07 +00:00
|
|
|
|
2019-07-25 07:58:34 +00:00
|
|
|
module.exports = (env, argv) => {
|
2020-05-12 22:24:41 +00:00
|
|
|
let mode = "production";
|
|
|
|
if (argv && argv.mode) {
|
|
|
|
mode = argv.mode;
|
|
|
|
}
|
2019-07-25 07:58:34 +00:00
|
|
|
|
2020-11-04 22:27:55 +00:00
|
|
|
const commitHash = require("child_process")
|
|
|
|
.execSync("git rev-parse --short HEAD")
|
|
|
|
.toString();
|
|
|
|
|
|
|
|
const commitDate = require("child_process")
|
|
|
|
.execSync("git log -1 --date=short --pretty=format:%cd")
|
|
|
|
.toString();
|
|
|
|
|
|
|
|
const channel = process.env.CFG_RELEASE_CHANNEL || "nightly".toLowerCase();
|
|
|
|
|
2020-05-12 22:24:41 +00:00
|
|
|
console.log(`Building ${mode}...`);
|
2019-07-25 07:58:34 +00:00
|
|
|
|
2020-05-12 22:24:41 +00:00
|
|
|
return {
|
|
|
|
entry: path.resolve(__dirname, "www/index.js"),
|
|
|
|
output: {
|
2020-10-21 21:53:37 +00:00
|
|
|
publicPath: "",
|
2020-05-12 22:24:41 +00:00
|
|
|
path: path.resolve(__dirname, "dist"),
|
|
|
|
filename: "index.js",
|
|
|
|
},
|
|
|
|
mode: mode,
|
2020-10-17 20:21:40 +00:00
|
|
|
experiments: {
|
|
|
|
syncWebAssembly: true,
|
|
|
|
},
|
2020-11-12 22:32:53 +00:00
|
|
|
devtool: "source-map",
|
2020-05-12 22:24:41 +00:00
|
|
|
plugins: [
|
|
|
|
new CleanWebpackPlugin(),
|
2020-11-04 22:27:55 +00:00
|
|
|
new webpack.DefinePlugin({
|
|
|
|
__COMMIT_HASH__: JSON.stringify(commitHash),
|
|
|
|
__COMMIT_DATE__: JSON.stringify(commitDate),
|
|
|
|
__CHANNEL__: JSON.stringify(channel),
|
|
|
|
}),
|
2020-05-21 06:34:14 +00:00
|
|
|
new CopyWebpackPlugin({
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
from: path.resolve(__dirname, "www/index.html"),
|
|
|
|
to: "index.html",
|
|
|
|
},
|
2020-05-26 18:11:48 +00:00
|
|
|
{
|
|
|
|
from: "LICENSE**",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
from: "README.md",
|
|
|
|
},
|
2020-05-21 06:34:14 +00:00
|
|
|
],
|
|
|
|
}),
|
2020-05-12 22:24:41 +00:00
|
|
|
],
|
|
|
|
};
|
2019-05-08 18:27:07 +00:00
|
|
|
};
|