@plaudit/webpack-extensions 1.0.4 → 1.2.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.
|
@@ -2,6 +2,6 @@ import type { Configuration } from "webpack";
|
|
|
2
2
|
export interface PlauditWordpressWebpackConfig {
|
|
3
3
|
legacyPostcssPlugins?: boolean;
|
|
4
4
|
variables?: Record<string, any>;
|
|
5
|
-
src: Record<string, string>;
|
|
5
|
+
src: string[] | Record<string, string>;
|
|
6
6
|
}
|
|
7
7
|
export default function (config: PlauditWordpressWebpackConfig, webpackConfig?: Configuration): Configuration[];
|
|
@@ -122,25 +122,34 @@ function default_1(config, webpackConfig = require("@wordpress/scripts/config/we
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
(
|
|
126
|
-
|
|
127
|
-
diagnosticOptions: {
|
|
128
|
-
semantic: true,
|
|
129
|
-
syntactic: true,
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
}), new webpack_remove_empty_scripts_1.default({ stage: webpack_remove_empty_scripts_1.default.STAGE_AFTER_PROCESS_PLUGINS, extensions: ['css', 'scss', 'sass', 'less', 'styl', 'pcss'] }), new BlockJSONStyleRemappingPlugin_1.default(), new AdditionalDependencyInjectorPlugin_1.default());
|
|
133
|
-
return Object.entries(config.src).map(([srcDir, dest]) => {
|
|
125
|
+
const sources = Array.isArray(config.src) ? config.src.map(s => [s, s]) : Object.entries(config.src);
|
|
126
|
+
return sources.map(([srcDir, dest]) => {
|
|
134
127
|
const srcRoot = node_path_1.default.join(process.cwd(), srcDir);
|
|
128
|
+
const copyFiles = srcDir !== dest;
|
|
129
|
+
const plugins = webpackConfig.plugins ?? [];
|
|
130
|
+
plugins.push(new fork_ts_checker_webpack_plugin_1.default({
|
|
131
|
+
typescript: {
|
|
132
|
+
diagnosticOptions: {
|
|
133
|
+
semantic: true,
|
|
134
|
+
syntactic: true,
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}), new webpack_remove_empty_scripts_1.default({ stage: webpack_remove_empty_scripts_1.default.STAGE_AFTER_PROCESS_PLUGINS, extensions: ['css', 'scss', 'sass', 'less', 'styl', 'pcss'] }));
|
|
138
|
+
if (copyFiles) {
|
|
139
|
+
plugins.push(new BlockJSONStyleRemappingPlugin_1.default());
|
|
140
|
+
}
|
|
141
|
+
plugins.push(new AdditionalDependencyInjectorPlugin_1.default());
|
|
135
142
|
return {
|
|
136
143
|
...webpackConfig,
|
|
137
144
|
output: {
|
|
138
145
|
...webpackConfig.output,
|
|
139
146
|
path: node_path_1.default.join(process.cwd(), dest)
|
|
140
147
|
},
|
|
141
|
-
plugins:
|
|
142
|
-
?
|
|
143
|
-
|
|
148
|
+
plugins: copyFiles
|
|
149
|
+
? plugins.map(plugin => plugin.constructor.name === 'CopyPlugin'
|
|
150
|
+
? new copy_webpack_plugin_1.default({ patterns: [{ from: '**/(block.json|*.(php|twig|svg))', context: srcRoot, noErrorOnMissing: true }] })
|
|
151
|
+
: plugin)
|
|
152
|
+
: plugins.filter(plugin => plugin.constructor.name !== 'CopyPlugin' && plugin.constructor.name !== 'CleanWebpackPlugin'),
|
|
144
153
|
entry: node_fs_1.default.readdirSync(srcRoot, 'utf8')
|
|
145
154
|
.map(dir => node_path_1.default.join(srcRoot, dir))
|
|
146
155
|
.filter(dir => node_fs_1.default.statSync(dir).isDirectory())
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plaudit/webpack-extensions",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepublishOnly": "rm -rf build && mkdir build && tsc",
|
|
6
6
|
"build": "tsc",
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"./wordpress-scripts-wrapper": "./build/wordpress-scripts-wrapper.js"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@types/node": "^
|
|
16
|
+
"@types/node": "^20.2.3",
|
|
17
17
|
"@types/webpack": "^5.28.1",
|
|
18
18
|
"@types/webpack-sources": "^3.2.0",
|
|
19
19
|
"postcss-load-config": "^4.0.1",
|
|
20
|
-
"postcss-loader": "^7.
|
|
20
|
+
"postcss-loader": "^7.3.0",
|
|
21
21
|
"ts-node": "^10.9.1",
|
|
22
22
|
"typescript": "^5.0.4"
|
|
23
23
|
},
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"@plaudit/postcss-silent-extend": "^3.0.0",
|
|
27
27
|
"@plaudit/postcss-strip-units": "^3.0.0",
|
|
28
28
|
"@plaudit/postcss-variables": "^1.0.0",
|
|
29
|
-
"@wordpress/scripts": "^26.
|
|
29
|
+
"@wordpress/scripts": "^26.4.0",
|
|
30
30
|
"autoprefixer": "^10.4.14",
|
|
31
31
|
"clean-webpack-plugin": "^4.0.0",
|
|
32
32
|
"copy-webpack-plugin": "^11.0.0",
|
|
33
|
-
"cssnano": "^6.0.
|
|
33
|
+
"cssnano": "^6.0.1",
|
|
34
34
|
"eslint": "^8.39.0",
|
|
35
35
|
"eslint-plugin-jsdoc": "^43.1.1",
|
|
36
36
|
"fork-ts-checker-webpack-plugin": "^8.0.0",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"postcss-short-spacing": "^4.0.0",
|
|
52
52
|
"react": "^18.2.0",
|
|
53
53
|
"react-dom": "^18.2.0",
|
|
54
|
-
"webpack": "^5.
|
|
54
|
+
"webpack": "^5.84.0",
|
|
55
55
|
"webpack-remove-empty-scripts": "^1.0.3",
|
|
56
56
|
"webpack-sources": "^3.2.3"
|
|
57
57
|
},
|