forked from ruffle-rs/ruffle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
72 lines (64 loc) · 2.06 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
import url from "url";
import json5 from "json5";
import CopyPlugin from "copy-webpack-plugin";
import TerserPlugin from "terser-webpack-plugin";
function transformPackage(content) {
const pkg = 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.
pkg.version =
versionChannel !== "stable"
? `${packageVersion}-${versionChannel}.${buildDate}`
: packageVersion;
return JSON.stringify(pkg);
}
export default function (_env, _argv) {
const mode = process.env.NODE_ENV || "production";
console.log(`Building ${mode}...`);
return {
mode,
entry: "./js/ruffle.js",
output: {
path: url.fileURLToPath(new URL("dist", import.meta.url)),
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" },
],
}),
],
};
}