mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-13 07:04:53 +09:00
The module sharing in Webpack works on a per import basis and therefore doesn't trigger when the value in the config is @clusterio/lib while the module imported is @clusterio/lib/config. This in turn caused a copy of lib to be bundled with each plugin. Fix by making sure each lib import is shared and specified in the configs.
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
"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.jsx",
|
|
devServer: {
|
|
contentBase: "./dist/web",
|
|
},
|
|
output: {
|
|
filename: "bundle.js",
|
|
path: path.resolve(__dirname, "dist", "web"),
|
|
},
|
|
plugins: [
|
|
new webpack.container.ModuleFederationPlugin({
|
|
name: "master",
|
|
shared: {
|
|
"@clusterio/lib/config": { singleton: true },
|
|
"@clusterio/lib/errors": { singleton: true },
|
|
"@clusterio/lib/helpers": { singleton: true },
|
|
"@clusterio/lib/link": { singleton: true },
|
|
"@clusterio/lib/logging": { singleton: true },
|
|
"@clusterio/lib/plugin": { singleton: true },
|
|
"@clusterio/lib/schema": { singleton: true },
|
|
"@clusterio/lib/users": { singleton: true },
|
|
"@clusterio/web_ui": { singleton: true },
|
|
"ajv": {},
|
|
"antd": { singleton: true },
|
|
"react": { singleton: true },
|
|
"react-dom": { singleton: true },
|
|
},
|
|
}),
|
|
],
|
|
});
|