forked from ruffle-rs/ruffle
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
74 lines (65 loc) · 2.09 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
/* eslint-env node */
const path = require("path");
const json5 = require("json5");
const CopyPlugin = require("copy-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
function transformPackage(content) {
const package = json5.parse(content);
const packageVersion = process.env.npm_package_version;
const versionChannel = process.env.CFG_RELEASE_CHANNEL || "nightly";
const buildDate = new Date()
.toISOString()
.substring(0, 10)
.replace(/-/g, ".");
// The npm registry requires the version to monotonically increase,
// so append the build date onto the end of the package version.
package.version =
versionChannel !== "stable"
? `${packageVersion}-${versionChannel}.${buildDate}`
: packageVersion;
return JSON.stringify(package);
}
module.exports = (_env, _argv) => {
const mode = process.env.NODE_ENV || "production";
console.log(`Building ${mode}...`);
return {
mode,
entry: "./js/ruffle.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: "ruffle.js",
publicPath: "",
chunkFilename: "core.ruffle.[contenthash].js",
clean: true,
},
performance: {
assetFilter: (assetFilename) =>
!/\.(map|wasm)$/i.test(assetFilename),
},
optimization: {
minimizer: [
new TerserPlugin({
terserOptions: {
output: {
ascii_only: true,
},
},
}),
],
},
devtool: "source-map",
plugins: [
new CopyPlugin({
patterns: [
{
from: "npm-package.json5",
to: "package.json",
transform: transformPackage,
},
{ from: "LICENSE*" },
{ from: "README.md" },
],
}),
],
};
};