Web:Login: update webpack config for work with json files as url

This commit is contained in:
Timofey Boyko 2023-01-30 19:18:49 +03:00
parent 2002564c1a
commit 17a1ab2152
2 changed files with 32 additions and 9 deletions

View File

@ -55,6 +55,29 @@ module.exports = {
type: "asset/resource", type: "asset/resource",
resourceQuery: /url/, // *.svg?url resourceQuery: /url/, // *.svg?url
}, },
{
test: /\.json$/i,
resourceQuery: /url/,
type: "javascript/auto",
use: [
{
loader: "file-loader",
options: {
name: (resourcePath, resourceQuery) => {
let result = resourcePath.split("public\\")[1].split("\\");
result.pop();
let folder = result.join("/");
folder += result.length === 0 ? "" : "/";
return `${folder}[name].[ext]?hash=[contenthash]`; // `${folder}/[name].[contenthash][ext]`;
},
},
},
],
},
{ {
test: /\.react.svg$/, test: /\.react.svg$/,
issuer: /\.[jt]sx?$/, issuer: /\.[jt]sx?$/,

View File

@ -100,15 +100,15 @@ const clientConfig = {
shared: { ...sharedDeps, ...deps }, shared: { ...sharedDeps, ...deps },
}), }),
new ExternalTemplateRemotesPlugin(), new ExternalTemplateRemotesPlugin(),
new CopyPlugin({ // new CopyPlugin({
patterns: [ // patterns: [
{ // {
context: path.resolve(__dirname, "../public"), // context: path.resolve(__dirname, "../public"),
from: "locales/**/*.json", // from: "locales/**/*.json",
transform: minifyJson, // transform: minifyJson,
}, // },
], // ],
}), // }),
new WebpackManifestPlugin(), new WebpackManifestPlugin(),
], ],
}; };