@plaudit/webpack-extensions 2.80.1 → 2.82.1
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.
package/build/shared.d.ts
CHANGED
|
@@ -110,6 +110,7 @@ export type PlauditWordpressWebpackConfig = {
|
|
|
110
110
|
useUnifiedLoader?: boolean;
|
|
111
111
|
includePostInitFallback?: boolean;
|
|
112
112
|
omitDistDev?: boolean;
|
|
113
|
+
onlyRunPostCSSOnPCSS?: boolean;
|
|
113
114
|
};
|
|
114
115
|
export type FileSegmentBlockEntrypointInfo = {
|
|
115
116
|
blockJsonOrigin: string;
|
|
@@ -11,10 +11,7 @@ const node_fs_1 = __importDefault(require("node:fs"));
|
|
|
11
11
|
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
12
12
|
const node_path_1 = __importDefault(require("node:path"));
|
|
13
13
|
const shared_1 = require("../shared");
|
|
14
|
-
|
|
15
|
-
function isInTheme() {
|
|
16
|
-
return isInThemeCache ?? (isInThemeCache = node_fs_1.default.existsSync(node_path_1.default.join(process.cwd(), "theme.json")));
|
|
17
|
-
}
|
|
14
|
+
const css_minimizer_webpack_plugin_1 = __importDefault(require("css-minimizer-webpack-plugin"));
|
|
18
15
|
function joinPossiblyAbsolutePaths(...paths) {
|
|
19
16
|
return paths.filter((p) => !!p)
|
|
20
17
|
.reduce((res, p) => !res || node_path_1.default.isAbsolute(p) ? p : node_path_1.default.join(res, p), '') || '.';
|
|
@@ -271,16 +268,6 @@ function commonMakeWebpackConfig(config, commonConfig, webpackConfig, externaliz
|
|
|
271
268
|
const { fixedRules, processingModules, updateCurrentVariables } = commonConfig;
|
|
272
269
|
const outPath = joinPossiblyAbsolutePaths(process.cwd(), config.outputDir);
|
|
273
270
|
let publicPath = webpackConfig.output?.publicPath;
|
|
274
|
-
if (isInTheme()) {
|
|
275
|
-
let prefix = process.cwd();
|
|
276
|
-
while (prefix.length > 5 && node_path_1.default.basename(prefix) !== "wp-content") {
|
|
277
|
-
prefix = node_path_1.default.dirname(prefix);
|
|
278
|
-
}
|
|
279
|
-
if (prefix.length > 5) {
|
|
280
|
-
prefix = node_path_1.default.dirname(prefix);
|
|
281
|
-
publicPath = `/${node_path_1.default.relative(prefix, outPath)}/`;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
271
|
let viableRoots = [...(Array.isArray(webpackConfig.context) ? webpackConfig.context : [webpackConfig.context ?? process.cwd()])];
|
|
285
272
|
let wpContentHolderDirectory = process.cwd();
|
|
286
273
|
while (wpContentHolderDirectory.length > 5) {
|
|
@@ -352,7 +339,11 @@ function commonMakeWebpackConfig(config, commonConfig, webpackConfig, externaliz
|
|
|
352
339
|
},
|
|
353
340
|
default: false
|
|
354
341
|
}
|
|
355
|
-
}
|
|
342
|
+
},
|
|
343
|
+
minimizer: [
|
|
344
|
+
...(webpackConfig.optimization?.minimizer || []),
|
|
345
|
+
new css_minimizer_webpack_plugin_1.default()
|
|
346
|
+
]
|
|
356
347
|
},
|
|
357
348
|
module: {
|
|
358
349
|
...webpackConfig.module,
|
|
@@ -105,8 +105,14 @@ function injectPostcssConfigOverrides(rules, config, variables, postcssFunctions
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
if (rule.test instanceof RegExp
|
|
109
|
-
rule.test
|
|
108
|
+
if (rule.test instanceof RegExp) {
|
|
109
|
+
if (rule.test.test("index.ts") || rule.test.test("index.mts")) { // Then this is the JavaScript and TypeScript rule
|
|
110
|
+
rule.test = /\.m?[jt]sx?$/; // This hacks in support for mjs and mts files
|
|
111
|
+
}
|
|
112
|
+
if (config.onlyRunPostCSSOnPCSS && rule.test.test("test.css") && !rule.test.test("test.pcss")) {
|
|
113
|
+
// We remove PostCSS processing from the .css file handling pipeline
|
|
114
|
+
rule.use = rule.use.filter(useItem => !useItem || typeof useItem !== 'object' || !useItem.loader?.includes('postcss-loader'));
|
|
115
|
+
}
|
|
110
116
|
}
|
|
111
117
|
}
|
|
112
118
|
if (rule.type === "asset/inline" && rule.test instanceof RegExp && rule.issuer instanceof RegExp && rule.test.test("test.svg") && rule.issuer.test("test.pcss")) {
|
|
@@ -157,7 +163,7 @@ function injectSupportForInliningSVGsAsStrings(rules) {
|
|
|
157
163
|
});
|
|
158
164
|
}
|
|
159
165
|
function buildVerifiedConfig(config) {
|
|
160
|
-
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, plainEntrypointsVersion = 1, srcDir = "", useUnifiedLoader = false, includePostInitFallback = false, omitDistDev = false } = config;
|
|
166
|
+
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, plainEntrypointsVersion = 1, srcDir = "", useUnifiedLoader = false, includePostInitFallback = false, omitDistDev = false, onlyRunPostCSSOnPCSS = false } = config;
|
|
161
167
|
let outputDir = config.outputDir ?? "";
|
|
162
168
|
if (outputDir && useUnifiedLoader && !omitDistDev && (process.env['SERVER_MODE'] ?? 'development') === 'development') {
|
|
163
169
|
outputDir += "-dev";
|
|
@@ -209,7 +215,8 @@ function buildVerifiedConfig(config) {
|
|
|
209
215
|
}
|
|
210
216
|
const cfg = {
|
|
211
217
|
currentVariables, postcss, standaloneBlocks, stats, variablesFilePath, verbose, externals, assumeGlobalizedPlauditLibraries, processTranslationConfigs, combineAssetMetadata,
|
|
212
|
-
useWebpackResourceFiltering, outputDir, extensionsVersion, plainEntrypointsVersion, srcDir, srcPrefixes, targetHandlePrefix, useUnifiedLoader, includePostInitFallback, omitDistDev
|
|
218
|
+
useWebpackResourceFiltering, outputDir, extensionsVersion, plainEntrypointsVersion, srcDir, srcPrefixes, targetHandlePrefix, useUnifiedLoader, includePostInitFallback, omitDistDev,
|
|
219
|
+
onlyRunPostCSSOnPCSS
|
|
213
220
|
};
|
|
214
221
|
// Destination -> source map
|
|
215
222
|
const allocatedDestinations = {};
|
|
@@ -566,7 +573,7 @@ function stripExtension(filepath) {
|
|
|
566
573
|
}
|
|
567
574
|
module.exports = function (config, webpackConfig = require("@wordpress/scripts/config/webpack.config")) {
|
|
568
575
|
const { cfg, sources } = buildVerifiedConfig(config);
|
|
569
|
-
if (Array.isArray(webpackConfig) && (0, shared_1.
|
|
576
|
+
if (Array.isArray(webpackConfig) && (0, shared_1.arrayIsLength)(webpackConfig, 1)) {
|
|
570
577
|
webpackConfig = webpackConfig[0];
|
|
571
578
|
}
|
|
572
579
|
if (Array.isArray(webpackConfig)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plaudit/webpack-extensions",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.82.1",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"files": [
|
|
6
6
|
"/build"
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@plaudit/gutenberg-api-extensions": "^2.
|
|
23
|
+
"@plaudit/gutenberg-api-extensions": "^2.83.0",
|
|
24
24
|
"@types/browser-sync-webpack-plugin": "^2.2.5",
|
|
25
|
-
"@types/node": "^
|
|
25
|
+
"@types/node": "^25.0.3",
|
|
26
26
|
"@types/postcss-functions": "^4.0.4",
|
|
27
27
|
"@types/tapable": "^2.3.0",
|
|
28
28
|
"@types/webpack": "^5.28.5",
|
|
@@ -39,13 +39,12 @@
|
|
|
39
39
|
"@plaudit/postcss-silent-extend": "^3.0.0",
|
|
40
40
|
"@plaudit/postcss-strip-units": "^3.0.0",
|
|
41
41
|
"@plaudit/postcss-variables": "^1.1.0",
|
|
42
|
-
"@wordpress/dependency-extraction-webpack-plugin": "^6.
|
|
43
|
-
"@wordpress/scripts": "^
|
|
42
|
+
"@wordpress/dependency-extraction-webpack-plugin": "^6.37.0",
|
|
43
|
+
"@wordpress/scripts": "^31.2.0",
|
|
44
44
|
"autoprefixer": "^10.4.23",
|
|
45
45
|
"browser-sync": "^3.0.4",
|
|
46
46
|
"copy-webpack-plugin": "10.2.4",
|
|
47
|
-
"
|
|
48
|
-
"eslint-plugin-jsdoc": "^48.11.0",
|
|
47
|
+
"css-minimizer-webpack-plugin": "^6.0.0",
|
|
49
48
|
"fork-ts-checker-webpack-plugin": "^9.1.0",
|
|
50
49
|
"http-proxy-middleware": "^3.0.5",
|
|
51
50
|
"json2php": "^0.0.12",
|