Web:Editor: update webpack config for work with json files as url
This commit is contained in:
parent
2ca548359a
commit
2002564c1a
@ -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: [
|
||||
|
@ -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(),
|
||||
],
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user