cssnano 5.0.12 → 5.0.16

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.
Files changed (2) hide show
  1. package/dist/index.js +19 -6
  2. package/package.json +58 -57
package/dist/index.js CHANGED
@@ -13,11 +13,23 @@ var _yaml = _interopRequireDefault(require("yaml"));
13
13
 
14
14
  var _lilconfig = require("lilconfig");
15
15
 
16
- var _isResolvable = _interopRequireDefault(require("is-resolvable"));
17
-
18
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
17
 
20
18
  const cssnano = 'cssnano';
19
+ /*
20
+ * @param {string} moduleId
21
+ * @returns {boolean}
22
+ */
23
+
24
+ function isResolvable(moduleId) {
25
+ try {
26
+ require.resolve(moduleId);
27
+
28
+ return true;
29
+ } catch (e) {
30
+ return false;
31
+ }
32
+ }
21
33
  /*
22
34
  * preset can be one of four possibilities:
23
35
  * preset = 'default'
@@ -26,6 +38,7 @@ const cssnano = 'cssnano';
26
38
  * preset = {plugins: []} <- already invoked function
27
39
  */
28
40
 
41
+
29
42
  function resolvePreset(preset) {
30
43
  let fn, options;
31
44
 
@@ -53,13 +66,13 @@ function resolvePreset(preset) {
53
66
  } // Try loading a preset from node_modules
54
67
 
55
68
 
56
- if ((0, _isResolvable.default)(fn)) {
69
+ if (isResolvable(fn)) {
57
70
  return require(fn)(options).plugins;
58
71
  }
59
72
 
60
73
  const sugar = `cssnano-preset-${fn}`; // Try loading a preset from node_modules (sugar)
61
74
 
62
- if ((0, _isResolvable.default)(sugar)) {
75
+ if (isResolvable(sugar)) {
63
76
  return require(sugar)(options).plugins;
64
77
  } // If all else fails, we probably have a typo in the config somewhere
65
78
 
@@ -114,12 +127,12 @@ const cssnanoPlugin = (options = {}) => {
114
127
  if (Array.isArray(plugin)) {
115
128
  const [pluginDef, opts = {}] = plugin;
116
129
 
117
- if (typeof pluginDef === 'string' && (0, _isResolvable.default)(pluginDef)) {
130
+ if (typeof pluginDef === 'string' && isResolvable(pluginDef)) {
118
131
  options.preset.plugins.push([require(pluginDef), opts]);
119
132
  } else {
120
133
  options.preset.plugins.push([pluginDef, opts]);
121
134
  }
122
- } else if (typeof plugin === 'string' && (0, _isResolvable.default)(plugin)) {
135
+ } else if (typeof plugin === 'string' && isResolvable(plugin)) {
123
136
  options.preset.plugins.push([require(plugin), {}]);
124
137
  } else {
125
138
  options.preset.plugins.push([plugin, {}]);
package/package.json CHANGED
@@ -1,58 +1,59 @@
1
1
  {
2
- "name": "cssnano",
3
- "version": "5.0.12",
4
- "description": "A modular minifier, built on top of the PostCSS ecosystem.",
5
- "main": "dist/index.js",
6
- "scripts": {
7
- "bundle-size": "webpack --json --config src/__tests__/_webpack.config.js | webpack-bundle-size-analyzer",
8
- "prebuild": "rimraf dist",
9
- "build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
10
- "prepare": "yarn build"
11
- },
12
- "funding": {
13
- "type": "opencollective",
14
- "url": "https://opencollective.com/cssnano"
15
- },
16
- "keywords": [
17
- "css",
18
- "compress",
19
- "minify",
20
- "optimise",
21
- "optimisation",
22
- "postcss",
23
- "postcss-plugin"
24
- ],
25
- "license": "MIT",
26
- "dependencies": {
27
- "lilconfig": "^2.0.3",
28
- "yaml": "^1.10.2",
29
- "cssnano-preset-default": "^5.1.8",
30
- "is-resolvable": "^1.1.0"
31
- },
32
- "homepage": "https://github.com/cssnano/cssnano",
33
- "author": {
34
- "name": "Ben Briggs",
35
- "email": "beneb.info@gmail.com",
36
- "url": "http://beneb.info"
37
- },
38
- "repository": "cssnano/cssnano",
39
- "files": [
40
- "dist",
41
- "LICENSE-MIT",
42
- "quickstart.js"
43
- ],
44
- "tonicExampleFilename": "quickstart.js",
45
- "bugs": {
46
- "url": "https://github.com/cssnano/cssnano/issues"
47
- },
48
- "engines": {
49
- "node": "^10 || ^12 || >=14.0"
50
- },
51
- "devDependencies": {
52
- "autoprefixer": "^10.3.7",
53
- "postcss": "^8.2.15"
54
- },
55
- "peerDependencies": {
56
- "postcss": "^8.2.15"
57
- }
58
- }
2
+ "name": "cssnano",
3
+ "version": "5.0.16",
4
+ "description": "A modular minifier, built on top of the PostCSS ecosystem.",
5
+ "main": "dist/index.js",
6
+ "funding": {
7
+ "type": "opencollective",
8
+ "url": "https://opencollective.com/cssnano"
9
+ },
10
+ "keywords": [
11
+ "css",
12
+ "compress",
13
+ "minify",
14
+ "optimise",
15
+ "optimisation",
16
+ "postcss",
17
+ "postcss-plugin"
18
+ ],
19
+ "license": "MIT",
20
+ "dependencies": {
21
+ "cssnano-preset-default": "^5.1.11",
22
+ "lilconfig": "^2.0.3",
23
+ "yaml": "^1.10.2"
24
+ },
25
+ "homepage": "https://github.com/cssnano/cssnano",
26
+ "author": {
27
+ "name": "Ben Briggs",
28
+ "email": "beneb.info@gmail.com",
29
+ "url": "http://beneb.info"
30
+ },
31
+ "repository": "cssnano/cssnano",
32
+ "files": [
33
+ "dist",
34
+ "LICENSE-MIT",
35
+ "quickstart.js"
36
+ ],
37
+ "tonicExampleFilename": "quickstart.js",
38
+ "bugs": {
39
+ "url": "https://github.com/cssnano/cssnano/issues"
40
+ },
41
+ "engines": {
42
+ "node": "^10 || ^12 || >=14.0"
43
+ },
44
+ "devDependencies": {
45
+ "autoprefixer": "^10.3.7",
46
+ "cssnano-preset-advanced": "^5.1.11",
47
+ "cssnano-preset-lite": "^2.0.2",
48
+ "postcss": "^8.2.15"
49
+ },
50
+ "peerDependencies": {
51
+ "postcss": "^8.2.15"
52
+ },
53
+ "scripts": {
54
+ "bundle-size": "webpack --json --config src/__tests__/_webpack.config.js | webpack-bundle-size-analyzer",
55
+ "prebuild": "rimraf dist",
56
+ "build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\""
57
+ },
58
+ "readme": "# cssnano\n\nFor documentation, please see the following links:\n\n* Repository: https://github.com/cssnano/cssnano\n* Website: http://cssnano.co\n"
59
+ }