Web: remove before-build-webpack-plugin and apply custom plugin for create autoGeneratedTranlsations files

This commit is contained in:
Timofey Boyko 2023-02-06 11:32:02 +03:00
parent cafc004db1
commit 6137e2a122
9 changed files with 71 additions and 67 deletions

View File

@ -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",

View File

@ -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: [
// {

View File

@ -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",

View File

@ -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)$/;

View File

@ -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",
}
);
}
);
},
},
],
};

View File

@ -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",

View File

@ -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],
};

View File

@ -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",
}
);
}
);
},
},
],
};

View File

@ -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"