@plaudit/webpack-extensions 2.51.0 → 2.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -24,6 +24,7 @@ type PlauditWordpressWebpackConfig = {
|
|
|
24
24
|
processTranslationConfigs?: boolean;
|
|
25
25
|
combineAssetMetadata?: boolean;
|
|
26
26
|
useWebpackResourceFiltering?: boolean;
|
|
27
|
+
outputDir?: string;
|
|
27
28
|
};
|
|
28
29
|
declare const _default: (config: PlauditWordpressWebpackConfig, webpackConfig?: Configuration[] | Configuration) => Configuration[];
|
|
29
30
|
export = _default;
|
|
@@ -21,7 +21,8 @@ const copy_webpack_plugin_1 = __importDefault(require("copy-webpack-plugin"));
|
|
|
21
21
|
const fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checker-webpack-plugin"));
|
|
22
22
|
const webpack_remove_empty_scripts_1 = __importDefault(require("webpack-remove-empty-scripts"));
|
|
23
23
|
function joinPossiblyAbsolutePaths(...paths) {
|
|
24
|
-
return paths.
|
|
24
|
+
return paths.filter((p) => !!p)
|
|
25
|
+
.reduce((res, p) => !res || node_path_1.default.isAbsolute(p) ? p : node_path_1.default.join(res, p), '') || '.';
|
|
25
26
|
}
|
|
26
27
|
function mapToRealEntrypoints(entrypoint, dir, mapper = (entrypoint) => entrypoint, lazyDependent, associatedQuery) {
|
|
27
28
|
return (Array.isArray(entrypoint) ? entrypoint : [entrypoint])
|
|
@@ -167,7 +168,7 @@ function replaceDefaultURLProcessing(useWebpackResourceFiltering) {
|
|
|
167
168
|
}
|
|
168
169
|
function injectPostcssConfigOverrides(rules, variables, postcssFunctionsConfig, verbose) {
|
|
169
170
|
const postcssConfig = (0, static_configs_1.postcssConfigBuilder)(verbose, name => variables(name) ?? (name === 'ENV' ? '' : undefined), postcssFunctionsConfig);
|
|
170
|
-
return rules.map(rule => {
|
|
171
|
+
return recursivelyAddParentDirectoryStepToImagesAndFonts(rules.map(rule => {
|
|
171
172
|
if (rule && typeof rule === 'object') {
|
|
172
173
|
if (Array.isArray(rule.use)) {
|
|
173
174
|
for (const useItem of rule.use) {
|
|
@@ -190,15 +191,32 @@ function injectPostcssConfigOverrides(rules, variables, postcssFunctionsConfig,
|
|
|
190
191
|
}
|
|
191
192
|
}
|
|
192
193
|
if (rule.type === "asset/inline" && rule.test instanceof RegExp && rule.issuer instanceof RegExp && rule.test.test("test.svg") && rule.issuer.test("test.pcss")) {
|
|
193
|
-
|
|
194
|
-
|
|
194
|
+
const { type: originalType, ...commonRuleParams } = rule;
|
|
195
|
+
return {
|
|
196
|
+
...commonRuleParams,
|
|
197
|
+
oneOf: [
|
|
198
|
+
{ type: originalType, resourceQuery: /string|inline/i },
|
|
199
|
+
{ type: "asset/resource", generator: { filename: "images/[name].[hash:8][ext]" } }
|
|
200
|
+
]
|
|
201
|
+
};
|
|
195
202
|
}
|
|
203
|
+
}
|
|
204
|
+
return rule;
|
|
205
|
+
}));
|
|
206
|
+
}
|
|
207
|
+
function recursivelyAddParentDirectoryStepToImagesAndFonts(rules) {
|
|
208
|
+
return rules.map(rule => {
|
|
209
|
+
if (rule && typeof rule === 'object') {
|
|
196
210
|
if (typeof rule.generator === 'object') {
|
|
197
211
|
const ruleGeneratorFilename = rule.generator["filename"];
|
|
198
212
|
if (typeof ruleGeneratorFilename === 'string' && (ruleGeneratorFilename.startsWith("images/") || ruleGeneratorFilename.startsWith("fonts/"))) {
|
|
199
213
|
rule.generator["filename"] = `../${ruleGeneratorFilename}`;
|
|
214
|
+
rule = { ...rule, generator: { ...rule.generator, filename: `../${ruleGeneratorFilename}` } };
|
|
200
215
|
}
|
|
201
216
|
}
|
|
217
|
+
if (rule.oneOf) {
|
|
218
|
+
rule = { ...rule, oneOf: recursivelyAddParentDirectoryStepToImagesAndFonts(rule.oneOf) };
|
|
219
|
+
}
|
|
202
220
|
}
|
|
203
221
|
return rule;
|
|
204
222
|
});
|
|
@@ -470,7 +488,7 @@ function processIndividualWebpackConfig(config, webpackConfig, sources, sharedCa
|
|
|
470
488
|
[baseDest.includes('.') ? node_path_1.default.basename(baseDest, node_path_1.default.extname(baseDest)) : baseDest]: srcRoot
|
|
471
489
|
});
|
|
472
490
|
}
|
|
473
|
-
const outPath = joinPossiblyAbsolutePaths(process.cwd(), srcIsDirectory ? destPath : node_path_1.default.dirname(destPath));
|
|
491
|
+
const outPath = joinPossiblyAbsolutePaths(process.cwd(), config.outputDir, srcIsDirectory ? destPath : node_path_1.default.dirname(destPath));
|
|
474
492
|
let publicPath = webpackConfig.output?.publicPath;
|
|
475
493
|
if (isInTheme()) {
|
|
476
494
|
let prefix = process.cwd();
|
|
@@ -589,7 +607,7 @@ function processIndividualWebpackConfig(config, webpackConfig, sources, sharedCa
|
|
|
589
607
|
}
|
|
590
608
|
module.exports = function (config, webpackConfig = require("@wordpress/scripts/config/webpack.config")) {
|
|
591
609
|
testForDuplicatedEntryPaths(config);
|
|
592
|
-
const { standaloneBlocks = false, stats = 'errors-warnings', variables: rawVariables, verbose = process.argv.includes('--verbose') || process.env['VERBOSE'] === 'true', postcss = {}, externals, assumeGlobalizedPlauditLibraries = true, processTranslationConfigs = true, combineAssetMetadata = true, useWebpackResourceFiltering = true } = config;
|
|
610
|
+
const { standaloneBlocks = false, stats = 'errors-warnings', variables: rawVariables, verbose = process.argv.includes('--verbose') || process.env['VERBOSE'] === 'true', postcss = {}, externals, assumeGlobalizedPlauditLibraries = true, processTranslationConfigs = true, combineAssetMetadata = true, useWebpackResourceFiltering = true, outputDir = "" } = config;
|
|
593
611
|
let variablesFilePath = undefined;
|
|
594
612
|
const currentVariables = rawVariables ?? {};
|
|
595
613
|
if (!rawVariables) {
|
|
@@ -597,7 +615,7 @@ module.exports = function (config, webpackConfig = require("@wordpress/scripts/c
|
|
|
597
615
|
}
|
|
598
616
|
const cfg = {
|
|
599
617
|
currentVariables, postcss, standaloneBlocks, stats, variablesFilePath, verbose, externals, assumeGlobalizedPlauditLibraries, processTranslationConfigs, combineAssetMetadata,
|
|
600
|
-
useWebpackResourceFiltering
|
|
618
|
+
useWebpackResourceFiltering, outputDir
|
|
601
619
|
};
|
|
602
620
|
const sources = Array.isArray(config.src) ? config.src.map(s => [s, s]) : Object.entries(config.src);
|
|
603
621
|
const sharedCache = {};
|