@plaudit/webpack-extensions 1.0.2 → 1.0.4

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) {
@@ -10,6 +10,7 @@ const BlockJSONStyleRemappingPlugin_1 = __importDefault(require("./BlockJSONStyl
10
10
  const copy_webpack_plugin_1 = __importDefault(require("copy-webpack-plugin"));
11
11
  const fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checker-webpack-plugin"));
12
12
  const webpack_remove_empty_scripts_1 = __importDefault(require("webpack-remove-empty-scripts"));
13
+ const cssnano_1 = __importDefault(require("cssnano"));
13
14
  function addEntryPointWithMapper(entrypoints, entrypoint, dir, mapper = (entrypoint) => entrypoint) {
14
15
  for (const ep of Array.isArray(entrypoint) ? entrypoint : [entrypoint]) {
15
16
  const mapped = node_path_1.default.join(dir, mapper(ep));
@@ -25,45 +26,50 @@ function default_1(config, webpackConfig = require("@wordpress/scripts/config/we
25
26
  // Nano Config
26
27
  // http://cssnano.co/guides/optimisations/ For the value to use click on one and then
27
28
  const nanoConfig = {
28
- safe: true,
29
- autoprefixer: false,
30
- calc: false,
31
- colormin: true,
32
- convertValues: false,
33
- discardComments: {
34
- remove: function (comment) {
35
- const commentKeepRegexp = /^!|@cms|@preserve|@cc_on|\bMIT\b|\bMPL\b|\bGPL\b|\bBSD\b|\bISCL\b|\(c\)|\bLicense\b|\bCopyright\b/i;
36
- return !commentKeepRegexp.test(comment);
29
+ preset: [
30
+ 'cssnano-preset-default',
31
+ {
32
+ safe: true,
33
+ autoprefixer: false,
34
+ calc: false,
35
+ colormin: true,
36
+ convertValues: false,
37
+ discardComments: {
38
+ remove(comment) {
39
+ const commentKeepRegexp = /^!|@cms|@preserve|@cc_on|\bMIT\b|\bMPL\b|\bGPL\b|\bBSD\b|\bISCL\b|\(c\)|\bLicense\b|\bCopyright\b/i;
40
+ return !commentKeepRegexp.test(comment);
41
+ }
42
+ },
43
+ discardDuplicates: true,
44
+ discardEmpty: true,
45
+ discardOverridden: true,
46
+ discardUnused: false,
47
+ mergeIdents: false,
48
+ mergeLonghand: true,
49
+ mergeRules: false,
50
+ minifyFontValues: true,
51
+ minifyGradients: true,
52
+ minifyParams: true,
53
+ minifySelectors: true,
54
+ normalizeCharset: true,
55
+ normalizeDisplayValues: true,
56
+ normalizePositions: true,
57
+ normalizeRepeatStyle: true,
58
+ normalizeString: true,
59
+ normalizeTimingFunctions: true,
60
+ normalizeUnicode: true,
61
+ normalizeUrl: true,
62
+ normalizeWhitespace: true,
63
+ orderedValues: true,
64
+ reduceIdents: false,
65
+ reduceInitial: true,
66
+ reduceTransforms: true,
67
+ svgo: false,
68
+ uniqueSelectors: true,
69
+ zindex: false,
70
+ filterPlugins: false // I don't know where this one came from. It is not listed in the documentation.
37
71
  }
38
- },
39
- discardDuplicates: true,
40
- discardEmpty: true,
41
- discardOverridden: true,
42
- discardUnused: false,
43
- mergeIdents: false,
44
- mergeLonghand: true,
45
- mergeRules: false,
46
- minifyFontValues: true,
47
- minifyGradients: true,
48
- minifyParams: true,
49
- minifySelectors: true,
50
- normalizeCharset: true,
51
- normalizeDisplayValues: true,
52
- normalizePositions: true,
53
- normalizeRepeatStyle: true,
54
- normalizeString: true,
55
- normalizeTimingFunctions: true,
56
- normalizeUnicode: true,
57
- normalizeUrl: true,
58
- normalizeWhitespace: true,
59
- orderedValues: true,
60
- reduceIdents: false,
61
- reduceInitial: true,
62
- reduceTransforms: true,
63
- svgo: false,
64
- uniqueSelectors: true,
65
- zindex: false,
66
- filterPlugins: false // I don't know where this one came from. It is not listed in the documentation.
72
+ ]
67
73
  };
68
74
  const postcssLoader = require.resolve('postcss-loader');
69
75
  if (postcssLoader && webpackConfig.module?.rules) {
@@ -93,7 +99,7 @@ function default_1(config, webpackConfig = require("@wordpress/scripts/config/we
93
99
  require("@plaudit/postcss-color-function")(),
94
100
  require("autoprefixer")(autoprefixerOptions),
95
101
  require("postcss-reporter")({ clearReportedMessages: true }),
96
- require("cssnano")(nanoConfig)
102
+ (0, cssnano_1.default)(nanoConfig)
97
103
  ]
98
104
  };
99
105
  for (const rule of webpackConfig.module.rules) {
@@ -123,7 +129,7 @@ function default_1(config, webpackConfig = require("@wordpress/scripts/config/we
123
129
  syntactic: true,
124
130
  },
125
131
  },
126
- }), 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
+ }), 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());
127
133
  return Object.entries(config.src).map(([srcDir, dest]) => {
128
134
  const srcRoot = node_path_1.default.join(process.cwd(), srcDir);
129
135
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "scripts": {
5
5
  "prepublishOnly": "rm -rf build && mkdir build && tsc",
6
6
  "build": "tsc",
@@ -13,11 +13,12 @@
13
13
  "./wordpress-scripts-wrapper": "./build/wordpress-scripts-wrapper.js"
14
14
  },
15
15
  "devDependencies": {
16
- "@types/node": "^18.15.13",
16
+ "@types/node": "^18.16.1",
17
17
  "@types/webpack": "^5.28.1",
18
18
  "@types/webpack-sources": "^3.2.0",
19
- "postcss-loader": "^7.2.4",
20
19
  "postcss-load-config": "^4.0.1",
20
+ "postcss-loader": "^7.2.4",
21
+ "ts-node": "^10.9.1",
21
22
  "typescript": "^5.0.4"
22
23
  },
23
24
  "dependencies": {
@@ -25,12 +26,13 @@
25
26
  "@plaudit/postcss-silent-extend": "^3.0.0",
26
27
  "@plaudit/postcss-strip-units": "^3.0.0",
27
28
  "@plaudit/postcss-variables": "^1.0.0",
28
- "@wordpress/scripts": "^26.2.0",
29
+ "@wordpress/scripts": "^26.3.0",
29
30
  "autoprefixer": "^10.4.14",
30
31
  "clean-webpack-plugin": "^4.0.0",
31
32
  "copy-webpack-plugin": "^11.0.0",
32
33
  "cssnano": "^6.0.0",
33
- "eslint": "^8.38.0",
34
+ "eslint": "^8.39.0",
35
+ "eslint-plugin-jsdoc": "^43.1.1",
34
36
  "fork-ts-checker-webpack-plugin": "^8.0.0",
35
37
  "postcss": "^8.4.23",
36
38
  "postcss-calc": "^8.2.4",
@@ -49,11 +51,11 @@
49
51
  "postcss-short-spacing": "^4.0.0",
50
52
  "react": "^18.2.0",
51
53
  "react-dom": "^18.2.0",
52
- "webpack": "^5.80.0",
54
+ "webpack": "^5.81.0",
53
55
  "webpack-remove-empty-scripts": "^1.0.3",
54
56
  "webpack-sources": "^3.2.3"
55
57
  },
56
58
  "resolutions": {
57
- "eslint-plugin-jsdoc": "^43.0.7"
59
+ "eslint-plugin-jsdoc": "^43.1.1"
58
60
  }
59
61
  }