@plaudit/webpack-extensions 2.1.0 → 2.1.2
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/wordpress-scripts-wrapper/BlockJSONStyleRemappingPlugin.js +17 -8
- package/build/wordpress-scripts-wrapper/static-configs.d.ts +1 -1
- package/build/wordpress-scripts-wrapper/static-configs.js +6 -8
- package/build/wordpress-scripts-wrapper.d.ts +0 -1
- package/build/wordpress-scripts-wrapper.js +2 -2
- package/package.json +2 -2
|
@@ -19,19 +19,28 @@ class BlockJSONStyleRemappingPlugin {
|
|
|
19
19
|
errorDetails: false,
|
|
20
20
|
timings: false
|
|
21
21
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
if (!stats.assets) {
|
|
23
|
+
throw new Error("Stats did not include assets despite them being requested");
|
|
24
|
+
}
|
|
25
|
+
if (!stats.modules) {
|
|
26
|
+
throw new Error("Stats did not include modules despite them being requested");
|
|
27
|
+
}
|
|
28
|
+
const assetSourceFiles = new Map(stats.assets
|
|
29
|
+
.map(asset => [asset.name, asset.info?.sourceFilename])
|
|
30
|
+
.filter((v) => v[0] !== undefined && v[1] !== undefined));
|
|
31
|
+
const singleFileChunkToOutputName = new Map(stats.assets
|
|
32
|
+
.filter((asset) => asset.chunks?.length === 1)
|
|
26
33
|
.filter(asset => !asset.name.endsWith('.asset.php'))
|
|
27
|
-
.map(asset => [
|
|
28
|
-
const singleFileInputToOutputName = new Map(stats.modules
|
|
34
|
+
.map(asset => [asset.chunks[0], asset.name]));
|
|
35
|
+
const singleFileInputToOutputName = new Map(stats.modules
|
|
36
|
+
.map(module => {
|
|
29
37
|
if (module.nameForCondition !== undefined && module.chunks?.length === 1) {
|
|
30
|
-
const output = singleFileChunkToOutputName.get(
|
|
38
|
+
const output = singleFileChunkToOutputName.get(module.chunks[0]);
|
|
31
39
|
return output !== undefined ? [module.nameForCondition, output] : undefined;
|
|
32
40
|
}
|
|
33
41
|
return undefined;
|
|
34
|
-
})
|
|
42
|
+
})
|
|
43
|
+
.filter((v) => v !== undefined));
|
|
35
44
|
const remapValue = (value, name, dirname) => {
|
|
36
45
|
if (value.startsWith("file:")) {
|
|
37
46
|
const styleInputPath = node_path_1.default.normalize(node_path_1.default.join(compiler.context, dirname, value.substring(5)));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { PostCSSLoaderOptions } from "postcss-loader/dist/config";
|
|
2
|
-
export declare function postcssConfigBuilder(verbose: boolean,
|
|
2
|
+
export declare function postcssConfigBuilder(verbose: boolean, variables: (name: string) => string | undefined): PostCSSLoaderOptions;
|
|
@@ -57,20 +57,18 @@ const nanoConfig = {
|
|
|
57
57
|
}
|
|
58
58
|
]
|
|
59
59
|
};
|
|
60
|
-
function postcssConfigBuilder(verbose,
|
|
60
|
+
function postcssConfigBuilder(verbose, variables) {
|
|
61
61
|
return {
|
|
62
62
|
plugins: [
|
|
63
63
|
require("postcss-import")(),
|
|
64
64
|
require("@plaudit/postcss-silent-extend")({ warnOfUnused: verbose }),
|
|
65
65
|
require("postcss-mixins")(),
|
|
66
66
|
require("@plaudit/postcss-variables")({ variables }),
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
require("postcss-fallback")() // Legacy
|
|
73
|
-
] : []),
|
|
67
|
+
require("postcss-quantity-queries")(),
|
|
68
|
+
require("postcss-short-position")(),
|
|
69
|
+
require("postcss-short-size")(),
|
|
70
|
+
require("postcss-short-spacing")(),
|
|
71
|
+
require("postcss-fallback")(),
|
|
74
72
|
require("postcss-property-lookup")({ logLevel: "warn" }),
|
|
75
73
|
require("@plaudit/postcss-strip-units")(),
|
|
76
74
|
require("postcss-media-minmax")(),
|
|
@@ -59,7 +59,7 @@ module.exports = function (config, webpackConfig = require("@wordpress/scripts/c
|
|
|
59
59
|
console.error(`Encountered multiple paths that produce the same effective bundle name:${duplicatedPaths}`);
|
|
60
60
|
process.exit(1);
|
|
61
61
|
}
|
|
62
|
-
const {
|
|
62
|
+
const { variables = ["variables.js", "preprocess/variables.js"].map(p => node_path_1.default.join(process.cwd(), p)).filter(p => node_fs_1.default.existsSync(p)).map(p => require(p))[0] ?? {}, verbose = process.argv.includes('--verbose') || process.env['VERBOSE'] === 'true' } = config;
|
|
63
63
|
const cssLoader = require.resolve('css-loader');
|
|
64
64
|
if (cssLoader && webpackConfig.module?.rules) {
|
|
65
65
|
for (const rule of webpackConfig.module.rules) {
|
|
@@ -74,7 +74,7 @@ module.exports = function (config, webpackConfig = require("@wordpress/scripts/c
|
|
|
74
74
|
}
|
|
75
75
|
let currentEntrypoint = '';
|
|
76
76
|
if (webpackConfig.module?.rules) {
|
|
77
|
-
const postcssConfig = (0, static_configs_1.postcssConfigBuilder)(verbose,
|
|
77
|
+
const postcssConfig = (0, static_configs_1.postcssConfigBuilder)(verbose, (name) => {
|
|
78
78
|
if (variables[name]) {
|
|
79
79
|
return variables[name];
|
|
80
80
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plaudit/webpack-extensions",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepublishOnly": "rm -rf build && mkdir build && tsc",
|
|
6
6
|
"build": "tsc",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"postcss-simple-vars": "^7.0.1",
|
|
57
57
|
"react": "^18.2.0",
|
|
58
58
|
"react-dom": "^18.2.0",
|
|
59
|
-
"webpack": "^5.
|
|
59
|
+
"webpack": "^5.88.0",
|
|
60
60
|
"webpack-remove-empty-scripts": "^1.0.3",
|
|
61
61
|
"webpack-sources": "^3.2.3"
|
|
62
62
|
},
|