@plaudit/webpack-extensions 1.0.3 → 1.1.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.
@@ -8,7 +8,7 @@ const webpack_sources_1 = require("webpack-sources");
8
8
  class BlockJSONStyleRemappingPlugin {
9
9
  apply(compiler) {
10
10
  compiler.hooks.compilation.tap("BlockJSONStyleRemappingPlugin", compilation => {
11
- compilation.hooks.processAssets.tap("BlockJSONStyleRemappingPlugin_ProcessAssets", compilationAssets => {
11
+ compilation.hooks.afterProcessAssets.tap("BlockJSONStyleRemappingPlugin_ProcessAssets", compilationAssets => {
12
12
  const stats = compilation.getStats().toJson({
13
13
  hash: true,
14
14
  publicPath: true,
@@ -23,6 +23,7 @@ class BlockJSONStyleRemappingPlugin {
23
23
  const assetSourceFiles = new Map(stats.assets?.map(asset => [asset.name, asset.info?.sourceFilename])
24
24
  .filter((v) => v[0] !== undefined && v[1] !== undefined) ?? []);
25
25
  const singleFileChunkToOutputName = new Map(stats.assets?.filter((asset) => asset.chunks?.length === 1)
26
+ .filter(asset => !asset.name.endsWith('.asset.php'))
26
27
  .map(asset => [toNumericChunkId(asset.chunks[0]), asset.name]) ?? []);
27
28
  const singleFileInputToOutputName = new Map(stats.modules?.map(module => {
28
29
  if (module.nameForCondition !== undefined && module.chunks?.length === 1) {
@@ -122,14 +122,20 @@ function default_1(config, webpackConfig = require("@wordpress/scripts/config/we
122
122
  }
123
123
  }
124
124
  }
125
- (webpackConfig.plugins ?? (webpackConfig.plugins = [])).push(new fork_ts_checker_webpack_plugin_1.default({
125
+ const copyFiles = !!process.env['WP_COPY_PHP_FILES_TO_DIST'];
126
+ const plugins = webpackConfig.plugins ?? [];
127
+ plugins.push(new fork_ts_checker_webpack_plugin_1.default({
126
128
  typescript: {
127
129
  diagnosticOptions: {
128
130
  semantic: true,
129
131
  syntactic: true,
130
- },
131
- },
132
- }), new webpack_remove_empty_scripts_1.default({ stage: webpack_remove_empty_scripts_1.default.STAGE_AFTER_PROCESS_PLUGINS }), new BlockJSONStyleRemappingPlugin_1.default(), new AdditionalDependencyInjectorPlugin_1.default());
132
+ }
133
+ }
134
+ }), 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'] }));
135
+ if (copyFiles) {
136
+ plugins.push(new BlockJSONStyleRemappingPlugin_1.default());
137
+ }
138
+ plugins.push(new AdditionalDependencyInjectorPlugin_1.default());
133
139
  return Object.entries(config.src).map(([srcDir, dest]) => {
134
140
  const srcRoot = node_path_1.default.join(process.cwd(), srcDir);
135
141
  return {
@@ -138,9 +144,11 @@ function default_1(config, webpackConfig = require("@wordpress/scripts/config/we
138
144
  ...webpackConfig.output,
139
145
  path: node_path_1.default.join(process.cwd(), dest)
140
146
  },
141
- plugins: webpackConfig.plugins.map(plugin => plugin.constructor.name === 'CopyPlugin'
142
- ? new copy_webpack_plugin_1.default({ patterns: [{ from: '**/(block.json|*.(php|twig|svg))', context: srcRoot, noErrorOnMissing: true }] })
143
- : plugin),
147
+ plugins: copyFiles
148
+ ? plugins.map(plugin => plugin.constructor.name === 'CopyPlugin'
149
+ ? new copy_webpack_plugin_1.default({ patterns: [{ from: '**/(block.json|*.(php|twig|svg))', context: srcRoot, noErrorOnMissing: true }] })
150
+ : plugin)
151
+ : plugins.filter(plugin => plugin.constructor.name !== 'CopyPlugin'),
144
152
  entry: node_fs_1.default.readdirSync(srcRoot, 'utf8')
145
153
  .map(dir => node_path_1.default.join(srcRoot, dir))
146
154
  .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",
3
+ "version": "1.1.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": "^18.15.13",
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.2.4",
20
+ "postcss-loader": "^7.3.0",
21
21
  "ts-node": "^10.9.1",
22
22
  "typescript": "^5.0.4"
23
23
  },
@@ -26,13 +26,13 @@
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.2.0",
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.0",
34
- "eslint": "^8.38.0",
35
- "eslint-plugin-jsdoc": "^43.0.7",
33
+ "cssnano": "^6.0.1",
34
+ "eslint": "^8.39.0",
35
+ "eslint-plugin-jsdoc": "^43.1.1",
36
36
  "fork-ts-checker-webpack-plugin": "^8.0.0",
37
37
  "postcss": "^8.4.23",
38
38
  "postcss-calc": "^8.2.4",
@@ -51,11 +51,11 @@
51
51
  "postcss-short-spacing": "^4.0.0",
52
52
  "react": "^18.2.0",
53
53
  "react-dom": "^18.2.0",
54
- "webpack": "^5.80.0",
54
+ "webpack": "^5.84.0",
55
55
  "webpack-remove-empty-scripts": "^1.0.3",
56
56
  "webpack-sources": "^3.2.3"
57
57
  },
58
58
  "resolutions": {
59
- "eslint-plugin-jsdoc": "^43.0.7"
59
+ "eslint-plugin-jsdoc": "^43.1.1"
60
60
  }
61
61
  }