ruffle/web/packages/extension/webpack.config.js

85 lines
3.0 KiB
JavaScript
Raw Normal View History

/* eslint-env node */
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
2019-08-20 04:29:53 +00:00
module.exports = (env, argv) => {
let mode = "production";
if (argv && argv.mode) {
mode = argv.mode;
}
2019-08-20 04:29:53 +00:00
console.log(`Building ${mode}...`);
2019-08-20 04:29:53 +00:00
return {
mode,
entry: {
popup: "./src/popup.js",
options: "./src/options.js",
content: "./src/content.js",
ruffle: "./src/ruffle.js",
background: "./src/background.js",
player: "./src/player.js",
},
output: {
path: path.resolve(__dirname, "assets/dist/"),
publicPath: "",
clean: true,
},
module: {
rules: [
{
test: /\.wasm$/i,
use: ["file-loader"],
},
],
},
plugins: [
new CopyPlugin({
2021-03-09 19:11:46 +00:00
patterns: [
{
from: "manifest.json",
to: "..",
transform(content) {
const manifest = JSON.parse(content.toString());
const packageVersion =
process.env.npm_package_version;
const versionChannel =
process.env.CFG_RELEASE_CHANNEL || "nightly";
const buildDate = new Date()
.toISOString()
.substring(0, 10);
// The extension marketplaces require the version to monotonically increase,
// so append the build date onto the end of the manifest version.
const version = process.env.BUILD_ID
? `${packageVersion}.${process.env.BUILD_ID}`
: packageVersion;
const version_name =
versionChannel === "nightly"
? `${packageVersion} nightly ${buildDate}`
: packageVersion;
Object.assign(manifest, { version, version_name });
2021-03-09 19:11:46 +00:00
if (env.firefox) {
const id =
process.env.FIREFOX_EXTENSION_ID ||
"ruffle@ruffle.rs";
2021-03-09 19:11:46 +00:00
Object.assign(manifest, {
browser_specific_settings: {
gecko: { id },
},
});
}
return JSON.stringify(manifest);
},
},
{ from: "LICENSE*" },
{ from: "README.md" },
],
}),
],
};
2019-08-20 04:29:53 +00:00
};