2020-05-11 19:37:57 +00:00
|
|
|
/* eslint-env node */
|
|
|
|
|
2021-02-17 04:39:46 +00:00
|
|
|
const path = require("path");
|
2021-03-04 20:59:10 +00:00
|
|
|
const CopyPlugin = require("copy-webpack-plugin");
|
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-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 {
|
2021-02-17 04:39:46 +00:00
|
|
|
mode,
|
2020-05-12 22:24:41 +00:00
|
|
|
entry: path.resolve(__dirname, "www/index.js"),
|
|
|
|
output: {
|
|
|
|
path: path.resolve(__dirname, "dist"),
|
|
|
|
filename: "index.js",
|
2021-02-17 04:39:46 +00:00
|
|
|
publicPath: "",
|
2021-03-03 14:19:46 +00:00
|
|
|
clean: true,
|
2020-05-12 22:24:41 +00:00
|
|
|
},
|
2021-01-10 03:36:05 +00:00
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.css$/i,
|
|
|
|
use: ["style-loader", "css-loader"],
|
|
|
|
},
|
2021-01-15 22:25:47 +00:00
|
|
|
{
|
|
|
|
test: /\.wasm$/i,
|
|
|
|
use: ["file-loader"],
|
|
|
|
},
|
2021-01-10 03:36:05 +00:00
|
|
|
],
|
|
|
|
},
|
2021-02-17 04:39:46 +00:00
|
|
|
devtool: "source-map",
|
|
|
|
plugins: [
|
2021-03-04 20:59:10 +00:00
|
|
|
new CopyPlugin({
|
2021-02-17 04:39:46 +00:00
|
|
|
patterns: [
|
2021-02-21 20:52:04 +00:00
|
|
|
{ from: path.resolve(__dirname, "www/index.html") },
|
2021-02-17 04:39:46 +00:00
|
|
|
{ from: "LICENSE*" },
|
|
|
|
{ from: "README.md" },
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
],
|
2020-05-12 22:24:41 +00:00
|
|
|
};
|
2019-05-08 18:27:07 +00:00
|
|
|
};
|