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

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

View File

@ -59,6 +59,35 @@ module.exports = {
type: "asset/resource",
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: /\.json$/,
resourceQuery: { not: [/url/] }, // exclude if *.json?url,
loader: "json-loader",
type: "javascript/auto",
},
],
},
plugins: [

View File

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