diff --git a/exp_auto_restart/index.ts b/exp_auto_restart/index.ts index 27420411..0d3274cc 100644 --- a/exp_auto_restart/index.ts +++ b/exp_auto_restart/index.ts @@ -47,4 +47,6 @@ export const plugin: lib.PluginDeclaration = { initialValue: false, }, }, + + webEntrypoint: "./web", }; diff --git a/exp_auto_restart/package.json b/exp_auto_restart/package.json index 57df55ac..c848a184 100644 --- a/exp_auto_restart/package.json +++ b/exp_auto_restart/package.json @@ -8,7 +8,7 @@ "type": "module", "main": "dist/node/index.js", "scripts": { - "prepare": "tsc --build", + "prepare": "tsc --build && webpack-cli --env production", "test": "tap --type-strip-only --disable-coverage --allow-empty-coverage test/*.test.js", "coverage": "tap --coverage-report=text test/*.test.js" }, @@ -24,7 +24,10 @@ "@clusterio/lib": "workspace:^", "@types/node": "catalog:", "tap": "^21.1.0", - "typescript": "catalog:" + "typescript": "catalog:", + "webpack": "catalog:", + "webpack-cli": "catalog:", + "webpack-merge": "catalog:" }, "publishConfig": { "access": "public" diff --git a/exp_auto_restart/tsconfig.browser.json b/exp_auto_restart/tsconfig.browser.json new file mode 100644 index 00000000..1ab2704e --- /dev/null +++ b/exp_auto_restart/tsconfig.browser.json @@ -0,0 +1,4 @@ +{ + "extends": "../tsconfig.browser.json", + "include": [ "web/**/*.tsx", "web/**/*.ts", "package.json" ], +} diff --git a/exp_auto_restart/tsconfig.json b/exp_auto_restart/tsconfig.json index a0473e75..303b8f28 100644 --- a/exp_auto_restart/tsconfig.json +++ b/exp_auto_restart/tsconfig.json @@ -1,6 +1,7 @@ { "files": [], "references": [ - { "path": "./tsconfig.node.json" } + { "path": "./tsconfig.node.json" }, + { "path": "./tsconfig.browser.json" } ] } diff --git a/exp_auto_restart/web/index.tsx b/exp_auto_restart/web/index.tsx new file mode 100644 index 00000000..e69de29b diff --git a/exp_auto_restart/webpack.config.cjs b/exp_auto_restart/webpack.config.cjs new file mode 100644 index 00000000..58150215 --- /dev/null +++ b/exp_auto_restart/webpack.config.cjs @@ -0,0 +1,29 @@ +"use strict"; +const path = require("path"); +const webpack = require("webpack"); +const { merge } = require("webpack-merge"); + +const common = require("@clusterio/web_ui/webpack.common"); + +module.exports = (env = {}) => merge(common(env), { + context: __dirname, + entry: "./web/index.tsx", + output: { + path: path.resolve(__dirname, "dist", "web"), + }, + plugins: [ + new webpack.container.ModuleFederationPlugin({ + name: "exp_auto_restart", + library: { type: "window", name: "plugin_exp_auto_restart" }, + exposes: { + "./": "./index.ts", + "./package.json": "./package.json", + "./web": "./web/index.tsx", + }, + shared: { + "@clusterio/lib": { import: false }, + "@clusterio/web_ui": { import: false }, + }, + }), + ], +});