diff --git a/packages/client/package.json b/packages/client/package.json index 069e0de724..65984ba828 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -62,7 +62,6 @@ "@babel/preset-typescript": "^7.18.6", "@svgr/webpack": "^5.5.0", "babel-loader": "^8.2.2", - "before-build-webpack": "^0.2.13", "clean-webpack-plugin": "^4.0.0", "copy-webpack-plugin": "^9.0.1", "css-loader": "^6.2.0", diff --git a/packages/client/webpack.config.js b/packages/client/webpack.config.js index 3b60fd7b0c..35f712d942 100644 --- a/packages/client/webpack.config.js +++ b/packages/client/webpack.config.js @@ -4,7 +4,7 @@ const HtmlWebpackPlugin = require("html-webpack-plugin"); const ModuleFederationPlugin = require("webpack").container .ModuleFederationPlugin; const DefinePlugin = require("webpack").DefinePlugin; -const WebpackBeforeBuildPlugin = require("before-build-webpack"); + const ExternalTemplateRemotesPlugin = require("external-remotes-plugin"); const TerserPlugin = require("terser-webpack-plugin"); const combineUrl = require("@docspace/common/utils/combineUrl"); @@ -22,6 +22,8 @@ const homepage = pkg.homepage; //combineUrl(window.DocSpaceConfig?.proxy?.url, p const title = pkg.title; const version = pkg.version; +const isAlreadyBuilding = false; + const config = { entry: "./src/index", target: "web", @@ -240,16 +242,22 @@ const config = { plugins: [ new CleanWebpackPlugin(), new ExternalTemplateRemotesPlugin(), - new WebpackBeforeBuildPlugin(async function (stats, callback) { - await beforeBuild( - [ - path.join(__dirname, "./public/locales"), - path.join(__dirname, "../../public/locales"), - ], - path.join(__dirname, "./src/helpers/autoGeneratedTranslations.js") - ); - callback(); - }), + { + apply: (compiler) => { + compiler.hooks.environment.tap( + "Create autoGeneratedTranslations file", + async () => { + await beforeBuild( + [ + path.join(__dirname, "./public/locales"), + path.join(__dirname, "../../public/locales"), + ], + path.join(__dirname, "./src/helpers/autoGeneratedTranslations.js") + ); + } + ); + }, + }, new CopyPlugin({ patterns: [ // { diff --git a/packages/editor/package.json b/packages/editor/package.json index 7626bdf7d5..543dfa4b76 100644 --- a/packages/editor/package.json +++ b/packages/editor/package.json @@ -33,7 +33,6 @@ "@svgr/webpack": "^6.2.1", "babel-loader": "^8.2.2", "babel-plugin-styled-components": "^1.12.0", - "before-build-webpack": "^0.2.13", "clean-webpack-plugin": "^4.0.0", "copy-webpack-plugin": "^11.0.0", "cross-env": "^7.0.3", diff --git a/packages/editor/webpack/webpack.base.js b/packages/editor/webpack/webpack.base.js index 28125fafbf..17230193f2 100644 --- a/packages/editor/webpack/webpack.base.js +++ b/packages/editor/webpack/webpack.base.js @@ -1,7 +1,5 @@ const path = require("path"); const FilterWarningsPlugin = require("webpack-filter-warnings-plugin"); -const PrebuildWebpackPlugin = require("prebuild-webpack-plugin"); -const beforeBuild = require("@docspace/common/utils/beforeBuild"); const scriptExtensions = /\.(tsx|ts|js|jsx|mjs)$/; const imageExtensions = /\.(bmp|gif|jpg|jpeg|png|ico)$/; diff --git a/packages/editor/webpack/webpack.client.js b/packages/editor/webpack/webpack.client.js index 3c9cf6acd1..cf9b932de6 100644 --- a/packages/editor/webpack/webpack.client.js +++ b/packages/editor/webpack/webpack.client.js @@ -9,7 +9,7 @@ const ExternalTemplateRemotesPlugin = require("external-remotes-plugin"); const CopyPlugin = require("copy-webpack-plugin"); const TerserPlugin = require("terser-webpack-plugin"); const minifyJson = require("@docspace/common/utils/minifyJson"); -const WebpackBeforeBuildPlugin = require("before-build-webpack"); + const beforeBuild = require("@docspace/common/utils/beforeBuild"); const sharedDeps = require("@docspace/common/constants/sharedDependencies"); @@ -137,29 +137,35 @@ const clientConfig = { ], }), new WebpackManifestPlugin(), - new WebpackBeforeBuildPlugin(async function (stats, callback) { - await beforeBuild( - [ - path.join(__dirname, "../public/locales"), - path.join(__dirname, "../../../public/locales"), - ], - path.join(__dirname, "../src/autoGeneratedTranslations.js"), - { - path: path.join(__dirname, "../../client/public/locales"), - files: [ - "ChangeOwnerPanel.json", - "EmbeddingPanel.json", - "Files.json", - "PeopleSelector.json", - "PeopleTranslations.json", - "SharingPanel.json", - "Translations.json", - ], - alias: "CLIENT_PUBLIC_DIR", - } - ); - callback(); - }), + { + apply: (compiler) => { + compiler.hooks.environment.tap( + "Create autoGeneratedTranslations file", + async () => { + await beforeBuild( + [ + path.join(__dirname, "../public/locales"), + path.join(__dirname, "../../../public/locales"), + ], + path.join(__dirname, "../src/autoGeneratedTranslations.js"), + { + path: path.join(__dirname, "../../client/public/locales"), + files: [ + "ChangeOwnerPanel.json", + "EmbeddingPanel.json", + "Files.json", + "PeopleSelector.json", + "PeopleTranslations.json", + "SharingPanel.json", + "Translations.json", + ], + alias: "CLIENT_PUBLIC_DIR", + } + ); + } + ); + }, + }, ], }; diff --git a/packages/login/package.json b/packages/login/package.json index 52f8dabf72..0acb098b23 100644 --- a/packages/login/package.json +++ b/packages/login/package.json @@ -73,7 +73,6 @@ "@types/styled-components": "^5.1.25", "@types/winston": "^2.4.4", "babel-loader": "^8.2.2", - "before-build-webpack": "^0.2.13", "clean-webpack-plugin": "^4.0.0", "copy-webpack-plugin": "^9.0.1", "css-loader": "^6.2.0", diff --git a/packages/login/src/client/helpers/utils.ts b/packages/login/src/client/helpers/utils.ts index a02bc4d48c..294d214e0c 100644 --- a/packages/login/src/client/helpers/utils.ts +++ b/packages/login/src/client/helpers/utils.ts @@ -72,7 +72,7 @@ export function initI18n(initialI18nStoreASC: IInitialI18nStoreASC): void { data: initialI18nStoreASC[lng][ns], }; } else if (ns != "Login") { - window.i18n.loaded[`${path?.replace("/login/", "/webpack")}`] = { + window.i18n.loaded[`${path?.replace("/login/", "/")}`] = { namespaces: ns, data: initialI18nStoreASC[lng][ns], }; diff --git a/packages/login/webpack/webpack.client.js b/packages/login/webpack/webpack.client.js index b70ac27626..7e92009d73 100644 --- a/packages/login/webpack/webpack.client.js +++ b/packages/login/webpack/webpack.client.js @@ -11,7 +11,6 @@ const TerserPlugin = require("terser-webpack-plugin"); const combineUrl = require("@docspace/common/utils/combineUrl"); const minifyJson = require("@docspace/common/utils/minifyJson"); const sharedDeps = require("@docspace/common/constants/sharedDependencies"); -const WebpackBeforeBuildPlugin = require("before-build-webpack"); const beforeBuild = require("@docspace/common/utils/beforeBuild"); const baseConfig = require("./webpack.base.js"); const pkg = require("../package.json"); @@ -139,21 +138,27 @@ const clientConfig = { ], }), new WebpackManifestPlugin(), - new WebpackBeforeBuildPlugin(async function (stats, callback) { - await beforeBuild( - [ - path.join(__dirname, "../public/locales"), - path.join(__dirname, "../../../public/locales"), - ], - path.join(__dirname, "../src/autoGeneratedTranslations.ts"), - { - path: path.join(__dirname, "../../client/public/locales"), - files: ["Files.json"], - alias: "CLIENT_PUBLIC_DIR", - } - ); - callback(); - }), + { + apply: (compiler) => { + compiler.hooks.environment.tap( + "Create autoGeneratedTranslations file", + async () => { + await beforeBuild( + [ + path.join(__dirname, "../public/locales"), + path.join(__dirname, "../../../public/locales"), + ], + path.join(__dirname, "../src/autoGeneratedTranslations.ts"), + { + path: path.join(__dirname, "../../client/public/locales"), + files: ["Files.json"], + alias: "CLIENT_PUBLIC_DIR", + } + ); + } + ); + }, + }, ], }; diff --git a/yarn.lock b/yarn.lock index 3b5c321f56..a247adca43 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2784,7 +2784,6 @@ __metadata: "@babel/preset-typescript": ^7.18.6 "@svgr/webpack": ^5.5.0 babel-loader: ^8.2.2 - before-build-webpack: ^0.2.13 clean-webpack-plugin: ^4.0.0 copy-to-clipboard: ^3.3.1 copy-webpack-plugin: ^9.0.1 @@ -2970,7 +2969,6 @@ __metadata: aws-crt: ^1.14.7 babel-loader: ^8.2.2 babel-plugin-styled-components: ^1.12.0 - before-build-webpack: ^0.2.13 bufferutil: ^4.0.6 clean-webpack-plugin: ^4.0.0 compression: ^1.7.4 @@ -3039,7 +3037,6 @@ __metadata: "@types/ws": ^8.5.3 aws-crt: ^1.14.7 babel-loader: ^8.2.2 - before-build-webpack: ^0.2.13 bufferutil: ^4.0.6 clean-webpack-plugin: ^4.0.0 compression: ^1.7.4 @@ -9158,13 +9155,6 @@ __metadata: languageName: node linkType: hard -"before-build-webpack@npm:^0.2.13": - version: 0.2.13 - resolution: "before-build-webpack@npm:0.2.13" - checksum: 9f31c0c8a6677ac86db885e6e24fe1329c3cbe9f23723d0c106b93e064549241a01653557b4608531266d9c51ff347f939be6fc1fb4a246cba6765b573e93793 - languageName: node - linkType: hard - "better-opn@npm:^2.1.1": version: 2.1.1 resolution: "better-opn@npm:2.1.1"