mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-25 08:23:13 +09:00
Webpack Build Improvements (#791)
* Bump @swc/core to 1.13.3 * Switch to using --mode production rather than --env Closes #792 * Add cache
This commit is contained in:
1 parent
d2bd1382ba
commit
681e78967f
20 files changed
+28
-27
No files matched your search
@@ -47,6 +47,9 @@ async function removeBuildArtifacts() {
|
|||||||
tasks.push(
|
tasks.push(
|
||||||
tryRemove(path.join(basePath, packageName, "dist"))
|
tryRemove(path.join(basePath, packageName, "dist"))
|
||||||
);
|
);
|
||||||
|
tasks.push(
|
||||||
|
tryRemove(path.join(basePath, packageName, "node_modules", ".cache"))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"version": "2.0.0-alpha.21",
|
"version": "2.0.0-alpha.21",
|
||||||
"main": "dist/node/index.js",
|
"main": "dist/node/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "tsc --build && webpack-cli --env production",
|
"prepare": "tsc --build && webpack-cli --mode production",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@clusterio/web_ui": "workspace:*",
|
"@clusterio/web_ui": "workspace:*",
|
||||||
"@swc/core": "^1.11.1",
|
"@swc/core": "^1.13.3",
|
||||||
"@types/busboy": "^1.5.0",
|
"@types/busboy": "^1.5.0",
|
||||||
"@types/compression": "^1.7.2",
|
"@types/compression": "^1.7.2",
|
||||||
"@types/express": "^4.17.17",
|
"@types/express": "^4.17.17",
|
||||||
|
|||||||
@@ -405,7 +405,6 @@ export default class Controller {
|
|||||||
const webpackConfigs = [];
|
const webpackConfigs = [];
|
||||||
|
|
||||||
if (args.dev) {
|
if (args.dev) {
|
||||||
|
|
||||||
webpackConfigs.push(require("../../../webpack.config")({})); // Path outside of build
|
webpackConfigs.push(require("../../../webpack.config")({})); // Path outside of build
|
||||||
}
|
}
|
||||||
if (args.devPlugin) {
|
if (args.devPlugin) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const { merge } = require("webpack-merge");
|
|||||||
|
|
||||||
const common = require("@clusterio/web_ui/webpack.common");
|
const common = require("@clusterio/web_ui/webpack.common");
|
||||||
|
|
||||||
module.exports = (env = {}) => merge(common(env), {
|
module.exports = (env = {}, argv = {}) => merge(common(env, argv), {
|
||||||
context: __dirname,
|
context: __dirname,
|
||||||
entry: "./web/index.tsx",
|
entry: "./web/index.tsx",
|
||||||
devServer: {
|
devServer: {
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ async function copyPluginTemplates(pluginName, templates) {
|
|||||||
|
|
||||||
// Files and dependences to support webpack
|
// Files and dependences to support webpack
|
||||||
if (webpack) {
|
if (webpack) {
|
||||||
prepare.push("webpack-cli --env production");
|
prepare.push("webpack-cli --mode production");
|
||||||
files.set("webpack.config.js", path.join(commonPath, "webpack.config.js"));
|
files.set("webpack.config.js", path.join(commonPath, "webpack.config.js"));
|
||||||
if (templates.includes("web")) {
|
if (templates.includes("web")) {
|
||||||
files.set(`web/index.${ext}x`, path.join(templatePath, `web/plugin.${ext}x`));
|
files.set(`web/index.${ext}x`, path.join(templatePath, `web/plugin.${ext}x`));
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const { merge } = require("webpack-merge");
|
|||||||
|
|
||||||
const common = require("@clusterio/web_ui/webpack.common");
|
const common = require("@clusterio/web_ui/webpack.common");
|
||||||
|
|
||||||
module.exports = (env = {}) => merge(common(env), {
|
module.exports = (env = {}, argv = {}) => merge(common(env, argv), {
|
||||||
context: __dirname,
|
context: __dirname,
|
||||||
entry: "./web/index.__ext__x",
|
entry: "./web/index.__ext__x",
|
||||||
output: {
|
output: {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
"@ant-design/icons": "^5.6.1",
|
"@ant-design/icons": "^5.6.1",
|
||||||
"@clusterio/lib": "workspace:*",
|
"@clusterio/lib": "workspace:*",
|
||||||
"@sinclair/typebox": "^0.30.4",
|
"@sinclair/typebox": "^0.30.4",
|
||||||
"@swc/core": "^1.11.1",
|
"@swc/core": "^1.13.3",
|
||||||
"antd": "^5.24.2",
|
"antd": "^5.24.2",
|
||||||
"assert": "^2.0.0",
|
"assert": "^2.0.0",
|
||||||
"browserify-zlib": "^0.2.0",
|
"browserify-zlib": "^0.2.0",
|
||||||
|
|||||||
@@ -4,9 +4,10 @@ const { CleanWebpackPlugin } = require("clean-webpack-plugin");
|
|||||||
const { WebpackManifestPlugin } = require("webpack-manifest-plugin");
|
const { WebpackManifestPlugin } = require("webpack-manifest-plugin");
|
||||||
const TerserPlugin = require("terser-webpack-plugin");
|
const TerserPlugin = require("terser-webpack-plugin");
|
||||||
|
|
||||||
module.exports = (env = {}) => ({
|
module.exports = (env = {}, argv = {}) => ({
|
||||||
mode: env.production ? "production" : "development",
|
mode: argv.mode ?? "development",
|
||||||
devtool: env.production ? "source-map" : "eval-source-map",
|
devtool: argv.mode === "production" ? "source-map" : "eval-source-map",
|
||||||
|
cache: { type: "filesystem" },
|
||||||
performance: {
|
performance: {
|
||||||
maxAssetSize: 2**21,
|
maxAssetSize: 2**21,
|
||||||
maxEntrypointSize: 2**21,
|
maxEntrypointSize: 2**21,
|
||||||
@@ -34,7 +35,7 @@ module.exports = (env = {}) => ({
|
|||||||
new webpack.NormalModuleReplacementPlugin(
|
new webpack.NormalModuleReplacementPlugin(
|
||||||
/@ant-design\/icons\/[A-Z]/,
|
/@ant-design\/icons\/[A-Z]/,
|
||||||
resource => {
|
resource => {
|
||||||
resource.request = resource.request.replace(/@ant-design\/icons/, "$&/es/icons");
|
resource.request = resource.request.replace("@ant-design\/icons", "$&/es/icons");
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -60,7 +61,7 @@ module.exports = (env = {}) => ({
|
|||||||
{
|
{
|
||||||
loader: require.resolve("css-loader"),
|
loader: require.resolve("css-loader"),
|
||||||
options: {
|
options: {
|
||||||
sourceMap: !env.production,
|
sourceMap: argv.mode !== "production",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -138,9 +139,7 @@ module.exports = (env = {}) => ({
|
|||||||
moduleIds: "deterministic",
|
moduleIds: "deterministic",
|
||||||
minimizer: [
|
minimizer: [
|
||||||
new TerserPlugin({
|
new TerserPlugin({
|
||||||
// TerserPlugin.swcMinify spams log with "false" after bump to @swc/core@1.11.1
|
minify: TerserPlugin.swcMinify,
|
||||||
// https://github.com/clusterio/clusterio/issues/737
|
|
||||||
// minify: TerserPlugin.swcMinify,
|
|
||||||
terserOptions: {
|
terserOptions: {
|
||||||
compress: {
|
compress: {
|
||||||
keep_classnames: true,
|
keep_classnames: true,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
"factorio"
|
"factorio"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "tsc --build && webpack-cli --env production",
|
"prepare": "tsc --build && webpack-cli --mode production",
|
||||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const { merge } = require("webpack-merge");
|
|||||||
|
|
||||||
const common = require("@clusterio/web_ui/webpack.common");
|
const common = require("@clusterio/web_ui/webpack.common");
|
||||||
|
|
||||||
module.exports = (env = {}) => merge(common(env), {
|
module.exports = (env = {}, argv = {}) => merge(common(env, argv), {
|
||||||
context: __dirname,
|
context: __dirname,
|
||||||
entry: "./web/index.tsx",
|
entry: "./web/index.tsx",
|
||||||
output: {
|
output: {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
"factorio"
|
"factorio"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "tsc --build && webpack-cli --env production",
|
"prepare": "tsc --build && webpack-cli --mode production",
|
||||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const { merge } = require("webpack-merge");
|
|||||||
|
|
||||||
const common = require("@clusterio/web_ui/webpack.common");
|
const common = require("@clusterio/web_ui/webpack.common");
|
||||||
|
|
||||||
module.exports = (env = {}) => merge(common(env), {
|
module.exports = (env = {}, argv = {}) => merge(common(env, argv), {
|
||||||
context: __dirname,
|
context: __dirname,
|
||||||
entry: "./web/index.tsx",
|
entry: "./web/index.tsx",
|
||||||
output: {
|
output: {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
"factorio"
|
"factorio"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "tsc --build && webpack-cli --env production",
|
"prepare": "tsc --build && webpack-cli --mode production",
|
||||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const { merge } = require("webpack-merge");
|
|||||||
|
|
||||||
const common = require("@clusterio/web_ui/webpack.common");
|
const common = require("@clusterio/web_ui/webpack.common");
|
||||||
|
|
||||||
module.exports = (env = {}) => merge(common(env), {
|
module.exports = (env = {}, argv = {}) => merge(common(env, argv), {
|
||||||
context: __dirname,
|
context: __dirname,
|
||||||
entry: "./web/index.tsx",
|
entry: "./web/index.tsx",
|
||||||
output: {
|
output: {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
"factorio"
|
"factorio"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "tsc --build && webpack-cli --env production",
|
"prepare": "tsc --build && webpack-cli --mode production",
|
||||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const { merge } = require("webpack-merge");
|
|||||||
|
|
||||||
const common = require("@clusterio/web_ui/webpack.common");
|
const common = require("@clusterio/web_ui/webpack.common");
|
||||||
|
|
||||||
module.exports = (env = {}) => merge(common(env), {
|
module.exports = (env = {}, argv = {}) => merge(common(env, argv), {
|
||||||
context: __dirname,
|
context: __dirname,
|
||||||
entry: "./web/index.tsx",
|
entry: "./web/index.tsx",
|
||||||
output: {
|
output: {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
"factorio"
|
"factorio"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "tsc --build && webpack-cli --env production",
|
"prepare": "tsc --build && webpack-cli --mode production",
|
||||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const { merge } = require("webpack-merge");
|
|||||||
|
|
||||||
const common = require("@clusterio/web_ui/webpack.common");
|
const common = require("@clusterio/web_ui/webpack.common");
|
||||||
|
|
||||||
module.exports = (env = {}) => merge(common(env), {
|
module.exports = (env = {}, argv = {}) => merge(common(env, argv), {
|
||||||
context: __dirname,
|
context: __dirname,
|
||||||
entry: "./web/index.tsx",
|
entry: "./web/index.tsx",
|
||||||
output: {
|
output: {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
"factorio"
|
"factorio"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "tsc --build && webpack-cli --env production",
|
"prepare": "tsc --build && webpack-cli --mode production",
|
||||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const { merge } = require("webpack-merge");
|
|||||||
|
|
||||||
const common = require("@clusterio/web_ui/webpack.common");
|
const common = require("@clusterio/web_ui/webpack.common");
|
||||||
|
|
||||||
module.exports = (env = {}) => merge(common(env), {
|
module.exports = (env = {}, argv = {}) => merge(common(env, argv), {
|
||||||
context: __dirname,
|
context: __dirname,
|
||||||
entry: "./web/index.tsx",
|
entry: "./web/index.tsx",
|
||||||
output: {
|
output: {
|
||||||
|
|||||||
Reference in new issue
Block a user