@plaudit/webpack-extensions 2.0.1 → 2.0.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.
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.postcssConfigBuilder = void 0;
|
|
7
|
+
const cssnano_1 = __importDefault(require("cssnano"));
|
|
8
|
+
// Options: calc
|
|
9
|
+
const calcOptions = { precision: 4, mediaQueries: true, selectors: true };
|
|
10
|
+
// Options: autoprefixerOptions
|
|
11
|
+
const autoprefixerOptions = { grid: "autoplace" };
|
|
12
|
+
// Nano Config
|
|
13
|
+
// http://cssnano.co/guides/optimisations/ For the value to use click on one and then
|
|
14
|
+
const nanoConfig = {
|
|
15
|
+
preset: [
|
|
16
|
+
'cssnano-preset-default',
|
|
17
|
+
{
|
|
18
|
+
safe: true,
|
|
19
|
+
autoprefixer: false,
|
|
20
|
+
calc: false,
|
|
21
|
+
colormin: true,
|
|
22
|
+
convertValues: false,
|
|
23
|
+
discardComments: {
|
|
24
|
+
remove(comment) {
|
|
25
|
+
const commentKeepRegexp = /^!|@cms|@preserve|@cc_on|\bMIT\b|\bMPL\b|\bGPL\b|\bBSD\b|\bISCL\b|\(c\)|\bLicense\b|\bCopyright\b/i;
|
|
26
|
+
return !commentKeepRegexp.test(comment);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
discardDuplicates: true,
|
|
30
|
+
discardEmpty: true,
|
|
31
|
+
discardOverridden: true,
|
|
32
|
+
discardUnused: false,
|
|
33
|
+
mergeIdents: false,
|
|
34
|
+
mergeLonghand: true,
|
|
35
|
+
mergeRules: false,
|
|
36
|
+
minifyFontValues: true,
|
|
37
|
+
minifyGradients: true,
|
|
38
|
+
minifyParams: true,
|
|
39
|
+
minifySelectors: true,
|
|
40
|
+
normalizeCharset: true,
|
|
41
|
+
normalizeDisplayValues: true,
|
|
42
|
+
normalizePositions: true,
|
|
43
|
+
normalizeRepeatStyle: true,
|
|
44
|
+
normalizeString: true,
|
|
45
|
+
normalizeTimingFunctions: true,
|
|
46
|
+
normalizeUnicode: true,
|
|
47
|
+
normalizeUrl: true,
|
|
48
|
+
normalizeWhitespace: true,
|
|
49
|
+
orderedValues: true,
|
|
50
|
+
reduceIdents: false,
|
|
51
|
+
reduceInitial: true,
|
|
52
|
+
reduceTransforms: true,
|
|
53
|
+
svgo: false,
|
|
54
|
+
uniqueSelectors: true,
|
|
55
|
+
zindex: false,
|
|
56
|
+
filterPlugins: false // I don't know where this one came from. It is not listed in the documentation.
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
};
|
|
60
|
+
function postcssConfigBuilder(verbose, legacyPostcssPlugins, variables) {
|
|
61
|
+
return {
|
|
62
|
+
plugins: [
|
|
63
|
+
require("postcss-import")(),
|
|
64
|
+
require("@plaudit/postcss-silent-extend")({ warnOfUnused: verbose }),
|
|
65
|
+
require("postcss-mixins")(),
|
|
66
|
+
require("@plaudit/postcss-variables")({ variables }),
|
|
67
|
+
...(legacyPostcssPlugins ? [
|
|
68
|
+
require("postcss-quantity-queries")(),
|
|
69
|
+
require("postcss-short-position")(),
|
|
70
|
+
require("postcss-short-size")(),
|
|
71
|
+
require("postcss-short-spacing")(),
|
|
72
|
+
require("postcss-fallback")() // Legacy
|
|
73
|
+
] : []),
|
|
74
|
+
require("postcss-property-lookup")({ logLevel: "warn" }),
|
|
75
|
+
require("@plaudit/postcss-strip-units")(),
|
|
76
|
+
require("postcss-media-minmax")(),
|
|
77
|
+
require("postcss-inline-svg")(),
|
|
78
|
+
require("postcss-nested")(),
|
|
79
|
+
require("postcss-calc")(calcOptions),
|
|
80
|
+
require("@plaudit/postcss-color-function")(),
|
|
81
|
+
require("autoprefixer")(autoprefixerOptions),
|
|
82
|
+
require("postcss-reporter")({ clearReportedMessages: true }),
|
|
83
|
+
(0, cssnano_1.default)(nanoConfig)
|
|
84
|
+
]
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
exports.postcssConfigBuilder = postcssConfigBuilder;
|
|
@@ -10,7 +10,7 @@ const browser_sync_webpack_plugin_1 = __importDefault(require("browser-sync-webp
|
|
|
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
|
|
13
|
+
const static_configs_1 = require("./wordpress-scripts-wrapper/static-configs");
|
|
14
14
|
function joinPossiblyAbsolutePaths(...paths) {
|
|
15
15
|
return paths.reduce((res, p) => !res || node_path_1.default.isAbsolute(p) ? p : node_path_1.default.join(res, p), '') || '.';
|
|
16
16
|
}
|
|
@@ -24,55 +24,7 @@ function addEntryPointWithMapper(entrypoints, entrypoint, dir, mapper = (entrypo
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
module.exports = function (config, webpackConfig = require("@wordpress/scripts/config/webpack.config")) {
|
|
27
|
-
const { legacyPostcssPlugins = false, 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') } = config;
|
|
28
|
-
// Nano Config
|
|
29
|
-
// http://cssnano.co/guides/optimisations/ For the value to use click on one and then
|
|
30
|
-
const nanoConfig = {
|
|
31
|
-
preset: [
|
|
32
|
-
'cssnano-preset-default',
|
|
33
|
-
{
|
|
34
|
-
safe: true,
|
|
35
|
-
autoprefixer: false,
|
|
36
|
-
calc: false,
|
|
37
|
-
colormin: true,
|
|
38
|
-
convertValues: false,
|
|
39
|
-
discardComments: {
|
|
40
|
-
remove(comment) {
|
|
41
|
-
const commentKeepRegexp = /^!|@cms|@preserve|@cc_on|\bMIT\b|\bMPL\b|\bGPL\b|\bBSD\b|\bISCL\b|\(c\)|\bLicense\b|\bCopyright\b/i;
|
|
42
|
-
return !commentKeepRegexp.test(comment);
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
discardDuplicates: true,
|
|
46
|
-
discardEmpty: true,
|
|
47
|
-
discardOverridden: true,
|
|
48
|
-
discardUnused: false,
|
|
49
|
-
mergeIdents: false,
|
|
50
|
-
mergeLonghand: true,
|
|
51
|
-
mergeRules: false,
|
|
52
|
-
minifyFontValues: true,
|
|
53
|
-
minifyGradients: true,
|
|
54
|
-
minifyParams: true,
|
|
55
|
-
minifySelectors: true,
|
|
56
|
-
normalizeCharset: true,
|
|
57
|
-
normalizeDisplayValues: true,
|
|
58
|
-
normalizePositions: true,
|
|
59
|
-
normalizeRepeatStyle: true,
|
|
60
|
-
normalizeString: true,
|
|
61
|
-
normalizeTimingFunctions: true,
|
|
62
|
-
normalizeUnicode: true,
|
|
63
|
-
normalizeUrl: true,
|
|
64
|
-
normalizeWhitespace: true,
|
|
65
|
-
orderedValues: true,
|
|
66
|
-
reduceIdents: false,
|
|
67
|
-
reduceInitial: true,
|
|
68
|
-
reduceTransforms: true,
|
|
69
|
-
svgo: false,
|
|
70
|
-
uniqueSelectors: true,
|
|
71
|
-
zindex: false,
|
|
72
|
-
filterPlugins: false // I don't know where this one came from. It is not listed in the documentation.
|
|
73
|
-
}
|
|
74
|
-
]
|
|
75
|
-
};
|
|
27
|
+
const { legacyPostcssPlugins = false, 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;
|
|
76
28
|
const cssLoader = require.resolve('css-loader');
|
|
77
29
|
if (cssLoader && webpackConfig.module?.rules) {
|
|
78
30
|
for (const rule of webpackConfig.module.rules) {
|
|
@@ -87,43 +39,15 @@ module.exports = function (config, webpackConfig = require("@wordpress/scripts/c
|
|
|
87
39
|
}
|
|
88
40
|
let currentEntrypoint = '';
|
|
89
41
|
if (webpackConfig.module?.rules) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
require("@plaudit/postcss-variables")({ variables: (name, srcNode) => {
|
|
100
|
-
if (variables[name]) {
|
|
101
|
-
return variables[name];
|
|
102
|
-
}
|
|
103
|
-
if (name === 'ENV') { // This is purely a backwards-compatibility issue.
|
|
104
|
-
return currentEntrypoint.endsWith('public.pcss') ? 'PUBLIC' : (currentEntrypoint.endsWith('block-editor.pcss') ? 'EDITOR' : '');
|
|
105
|
-
}
|
|
106
|
-
return undefined;
|
|
107
|
-
} }),
|
|
108
|
-
...(legacyPostcssPlugins ? [
|
|
109
|
-
require("postcss-quantity-queries")(),
|
|
110
|
-
require("postcss-short-position")(),
|
|
111
|
-
require("postcss-short-size")(),
|
|
112
|
-
require("postcss-short-spacing")(),
|
|
113
|
-
require("postcss-fallback")() // Legacy
|
|
114
|
-
] : []),
|
|
115
|
-
require("postcss-property-lookup")({ logLevel: "warn" }),
|
|
116
|
-
require("@plaudit/postcss-strip-units")(),
|
|
117
|
-
require("postcss-media-minmax")(),
|
|
118
|
-
require("postcss-inline-svg")(),
|
|
119
|
-
require("postcss-nested")(),
|
|
120
|
-
require("postcss-calc")(calcOptions),
|
|
121
|
-
require("@plaudit/postcss-color-function")(),
|
|
122
|
-
require("autoprefixer")(autoprefixerOptions),
|
|
123
|
-
require("postcss-reporter")({ clearReportedMessages: true }),
|
|
124
|
-
(0, cssnano_1.default)(nanoConfig)
|
|
125
|
-
]
|
|
126
|
-
};
|
|
42
|
+
const postcssConfig = (0, static_configs_1.postcssConfigBuilder)(verbose, legacyPostcssPlugins, (name) => {
|
|
43
|
+
if (variables[name]) {
|
|
44
|
+
return variables[name];
|
|
45
|
+
}
|
|
46
|
+
if (name === 'ENV') { // This is purely a backwards-compatibility issue.
|
|
47
|
+
return currentEntrypoint.endsWith('public.pcss') ? 'PUBLIC' : (currentEntrypoint.endsWith('block-editor.pcss') ? 'EDITOR' : '');
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
});
|
|
127
51
|
for (const rule of webpackConfig.module.rules) {
|
|
128
52
|
if (typeof rule === 'object' && Array.isArray(rule.use)) {
|
|
129
53
|
for (const useItem of rule.use) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plaudit/webpack-extensions",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepublishOnly": "rm -rf build && mkdir build && tsc",
|
|
6
6
|
"build": "tsc",
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/browser-sync-webpack-plugin": "^2.2.2",
|
|
17
|
-
"@types/node": "^20.
|
|
17
|
+
"@types/node": "^20.3.0",
|
|
18
18
|
"@types/tapable": "^2.2.3",
|
|
19
19
|
"@types/webpack": "^5.28.1",
|
|
20
20
|
"@types/webpack-sources": "^3.2.0",
|
|
21
21
|
"postcss-load-config": "^4.0.1",
|
|
22
|
-
"postcss-loader": "^7.3.
|
|
22
|
+
"postcss-loader": "^7.3.3",
|
|
23
23
|
"ts-node": "^10.9.1",
|
|
24
24
|
"typescript": "^5.1.3"
|
|
25
25
|
},
|