@plaudit/webpack-extensions 0.0.12 → 0.0.14

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.
@@ -4,4 +4,4 @@ export interface PlauditWordpressWebpackConfig {
4
4
  variables: Record<string, any>;
5
5
  src: string;
6
6
  }
7
- export default function (config: Partial<PlauditWordpressWebpackConfig>, webpackConfig?: Configuration): Configuration;
7
+ export default function (config?: Partial<PlauditWordpressWebpackConfig>, webpackConfig?: Configuration): Configuration;
@@ -18,7 +18,7 @@ function addEntryPointWithFilter(entrypoints, entrypoint, mapper = (entrypoint)
18
18
  entrypoints.push(mapper(entrypoint));
19
19
  }
20
20
  }
21
- function default_1(config, webpackConfig = require("@wordpress/scripts/config/webpack.config")) {
21
+ function default_1(config = {}, webpackConfig = require("@wordpress/scripts/config/webpack.config")) {
22
22
  const { legacyPostcssPlugins = false, variables = node_fs_1.default.existsSync("./variables.js") ? require("./variables.js") : {}, // TODO: There must be a better way to handle this...
23
23
  src = process.env['WP_SRC_DIRECTORY'] || 'src' } = config;
24
24
  (webpackConfig.plugins ?? (webpackConfig.plugins = [])).push(new fork_ts_checker_webpack_plugin_1.default({
@@ -29,6 +29,49 @@ function default_1(config, webpackConfig = require("@wordpress/scripts/config/we
29
29
  },
30
30
  },
31
31
  }), 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(), new copy_webpack_plugin_1.default({ patterns: [{ from: '**/*.(twig|svg)', context: src, noErrorOnMissing: true }] }));
32
+ // Nano Config
33
+ // http://cssnano.co/guides/optimisations/ For the value to use click on one and then
34
+ const nanoConfig = {
35
+ safe: true,
36
+ autoprefixer: false,
37
+ calc: false,
38
+ colormin: true,
39
+ convertValues: false,
40
+ discardComments: {
41
+ remove: function (comment) {
42
+ const commentKeepRegexp = /^!|@cms|@preserve|@cc_on|\bMIT\b|\bMPL\b|\bGPL\b|\bBSD\b|\bISCL\b|\(c\)|\bLicense\b|\bCopyright\b/i;
43
+ return !commentKeepRegexp.test(comment);
44
+ }
45
+ },
46
+ discardDuplicates: true,
47
+ discardEmpty: true,
48
+ discardOverridden: true,
49
+ discardUnused: false,
50
+ mergeIdents: false,
51
+ mergeLonghand: true,
52
+ mergeRules: false,
53
+ minifyFontValues: true,
54
+ minifyGradients: true,
55
+ minifyParams: true,
56
+ minifySelectors: true,
57
+ normalizeCharset: true,
58
+ normalizeDisplayValues: true,
59
+ normalizePositions: true,
60
+ normalizeRepeatStyle: true,
61
+ normalizeString: true,
62
+ normalizeTimingFunctions: true,
63
+ normalizeUnicode: true,
64
+ normalizeUrl: true,
65
+ normalizeWhitespace: true,
66
+ orderedValues: true,
67
+ reduceIdents: false,
68
+ reduceInitial: true,
69
+ reduceTransforms: true,
70
+ svgo: false,
71
+ uniqueSelectors: true,
72
+ zindex: false,
73
+ filterPlugins: false // I don't know where this one came from. It is not listed in the documentation.
74
+ };
32
75
  if (webpackConfig.module?.rules) {
33
76
  const postcssLoader = require.resolve('postcss-loader');
34
77
  // Options: calc
@@ -56,10 +99,10 @@ function default_1(config, webpackConfig = require("@wordpress/scripts/config/we
56
99
  require("postcss-calc")(calcOptions),
57
100
  require("@plaudit/postcss-color-function")(),
58
101
  require("autoprefixer")(autoprefixerOptions),
59
- require("postcss-reporter")({ clearReportedMessages: true }) // OnceExit
102
+ require("postcss-reporter")({ clearReportedMessages: true }),
103
+ require("cssnano")(nanoConfig)
60
104
  ]
61
105
  };
62
- //TODO: Add CSSNano
63
106
  for (const rule of webpackConfig.module.rules) {
64
107
  if (typeof rule === 'object' && Array.isArray(rule.use)) {
65
108
  for (const useItem of rule.use) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "scripts": {
5
5
  "prepublishOnly": "rm -rf build && mkdir build && tsc",
6
6
  "build": "tsc",
@@ -16,8 +16,8 @@
16
16
  "@types/node": "^18.15.12",
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
21
  "typescript": "^5.0.4"
22
22
  },
23
23
  "dependencies": {
@@ -29,6 +29,7 @@
29
29
  "autoprefixer": "^10.4.14",
30
30
  "clean-webpack-plugin": "^4.0.0",
31
31
  "copy-webpack-plugin": "^11.0.0",
32
+ "cssnano": "^6.0.0",
32
33
  "eslint": "^8.38.0",
33
34
  "eslint-plugin-jsdoc": "^43.0.3",
34
35
  "fork-ts-checker-webpack-plugin": "^8.0.0",
@@ -39,6 +40,7 @@
39
40
  "postcss-import": "^15.1.0",
40
41
  "postcss-inline-svg": "^6.0.0",
41
42
  "postcss-media-minmax": "^5.0.0",
43
+ "postcss-mixins": "^9.0.4",
42
44
  "postcss-nested": "^6.0.1",
43
45
  "postcss-property-lookup": "^3.0.0",
44
46
  "postcss-quantity-queries": "^0.5.0",
@@ -62,6 +64,7 @@
62
64
  "autoprefixer": "^10.4.14",
63
65
  "clean-webpack-plugin": "^4.0.0",
64
66
  "copy-webpack-plugin": "^11.0.0",
67
+ "cssnano": "^6.0.0",
65
68
  "eslint": "^8.38.0",
66
69
  "eslint-plugin-jsdoc": "^43.0.3",
67
70
  "fork-ts-checker-webpack-plugin": "^8.0.0",
@@ -72,6 +75,7 @@
72
75
  "postcss-import": "^15.1.0",
73
76
  "postcss-inline-svg": "^6.0.0",
74
77
  "postcss-media-minmax": "^5.0.0",
78
+ "postcss-mixins": "^9.0.4",
75
79
  "postcss-nested": "^6.0.1",
76
80
  "postcss-property-lookup": "^3.0.0",
77
81
  "postcss-quantity-queries": "^0.5.0",