@node-minify/cssnano 7.1.0 → 8.0.0-beta.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.
@@ -0,0 +1,18 @@
1
+ import { MinifierOptions } from '@node-minify/types';
2
+
3
+ /*!
4
+ * node-minify
5
+ * Copyright(c) 2011-2022 Rodolphe Stoclin
6
+ * MIT Licensed
7
+ */
8
+
9
+ /**
10
+ * Run cssnano.
11
+ *
12
+ * @param {Object} settings
13
+ * @param {String} content
14
+ * @param {Function} callback
15
+ */
16
+ declare const minifyCssnano: ({ settings, content, callback, index }: MinifierOptions) => Promise<any>;
17
+
18
+ export { minifyCssnano as default };
package/dist/index.js ADDED
@@ -0,0 +1,58 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+
25
+ // src/index.ts
26
+ var src_exports = {};
27
+ __export(src_exports, {
28
+ default: () => src_default
29
+ });
30
+ module.exports = __toCommonJS(src_exports);
31
+ var import_postcss = __toESM(require("postcss"));
32
+ var import_cssnano = __toESM(require("cssnano"));
33
+ var import_utils = require("@node-minify/utils");
34
+ var minifyCssnano = async ({ settings, content, callback, index }) => {
35
+ let contentMinified = { css: "" };
36
+ try {
37
+ contentMinified = await (0, import_postcss.default)([import_cssnano.default]).process(content || "", { from: void 0 });
38
+ } catch (e) {
39
+ if (callback) {
40
+ return callback(e);
41
+ }
42
+ }
43
+ if (settings && !settings.content) {
44
+ import_utils.utils.writeFile({ file: settings.output, content: contentMinified.css, index });
45
+ }
46
+ if (callback) {
47
+ return callback(null, contentMinified.css);
48
+ }
49
+ return contentMinified.css;
50
+ };
51
+ var src_default = minifyCssnano;
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {});
54
+ /*!
55
+ * node-minify
56
+ * Copyright(c) 2011-2022 Rodolphe Stoclin
57
+ * MIT Licensed
58
+ */
package/dist/index.mjs ADDED
@@ -0,0 +1,30 @@
1
+ // src/index.ts
2
+ import postcss from "postcss";
3
+ import cssnano from "cssnano";
4
+ import { utils } from "@node-minify/utils";
5
+ var minifyCssnano = async ({ settings, content, callback, index }) => {
6
+ let contentMinified = { css: "" };
7
+ try {
8
+ contentMinified = await postcss([cssnano]).process(content || "", { from: void 0 });
9
+ } catch (e) {
10
+ if (callback) {
11
+ return callback(e);
12
+ }
13
+ }
14
+ if (settings && !settings.content) {
15
+ utils.writeFile({ file: settings.output, content: contentMinified.css, index });
16
+ }
17
+ if (callback) {
18
+ return callback(null, contentMinified.css);
19
+ }
20
+ return contentMinified.css;
21
+ };
22
+ var src_default = minifyCssnano;
23
+ export {
24
+ src_default as default
25
+ };
26
+ /*!
27
+ * node-minify
28
+ * Copyright(c) 2011-2022 Rodolphe Stoclin
29
+ * MIT Licensed
30
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-minify/cssnano",
3
- "version": "7.1.0",
3
+ "version": "8.0.0-beta.0",
4
4
  "description": "cssnano plugin for @node-minify",
5
5
  "keywords": [
6
6
  "compressor",
@@ -11,16 +11,23 @@
11
11
  "author": "Rodolphe Stoclin <srodolphe@gmail.com>",
12
12
  "homepage": "https://github.com/srod/node-minify/tree/master/packages/cssnano#readme",
13
13
  "license": "MIT",
14
- "main": "lib/cssnano.js",
15
14
  "engines": {
16
15
  "node": ">=14.0.0"
17
16
  },
18
17
  "directories": {
19
- "lib": "lib",
18
+ "lib": "dist",
20
19
  "test": "__tests__"
21
20
  },
21
+ "main": "./dist/index.js",
22
+ "module": "./dist/index.mjs",
23
+ "types": "./dist/index.d.ts",
24
+ "exports": {
25
+ "require": "./dist/index.js",
26
+ "import": "./dist/index.mjs",
27
+ "types": "./dist/index.d.ts"
28
+ },
22
29
  "files": [
23
- "lib"
30
+ "dist/**/*"
24
31
  ],
25
32
  "publishConfig": {
26
33
  "access": "public"
@@ -32,10 +39,18 @@
32
39
  "bugs": {
33
40
  "url": "https://github.com/srod/node-minify/issues"
34
41
  },
42
+ "scripts": {
43
+ "clean": "pnpm dlx rimraf dist",
44
+ "build": "npm run clean && tsup src/index.ts --format cjs,esm --dts --clean",
45
+ "prepublishOnly": "npm run build"
46
+ },
35
47
  "dependencies": {
36
- "@node-minify/utils": "^7.1.0",
48
+ "@node-minify/utils": "8.0.0-beta.0",
37
49
  "cssnano": "^5.0.0",
38
50
  "postcss": "8.4.19"
39
51
  },
40
- "gitHead": "94cef2d5d653c3bddc3e603b4e25c135b0b6f4b3"
52
+ "devDependencies": {
53
+ "@node-minify/types": "8.0.0-beta.0"
54
+ },
55
+ "gitHead": "0507c6190577e1939997a8231b07952ba167a780"
41
56
  }
package/lib/cssnano.js DELETED
@@ -1,56 +0,0 @@
1
- "use strict";
2
-
3
- var _postcss = _interopRequireDefault(require("postcss"));
4
- var _cssnano = _interopRequireDefault(require("cssnano"));
5
- var _utils = require("@node-minify/utils");
6
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
7
- /*!
8
- * node-minify
9
- * Copyright(c) 2011-2022 Rodolphe Stoclin
10
- * MIT Licensed
11
- */
12
-
13
- /**
14
- * Module dependencies.
15
- */
16
-
17
- /**
18
- * Run cssnano.
19
- *
20
- * @param {Object} settings
21
- * @param {String} content
22
- * @param {Function} callback
23
- */
24
- const minifyCssnano = async ({
25
- settings,
26
- content,
27
- callback,
28
- index
29
- }) => {
30
- let contentMinified;
31
- try {
32
- contentMinified = await (0, _postcss.default)([_cssnano.default]).process(content, {
33
- from: undefined
34
- });
35
- } catch (e) {
36
- if (callback) {
37
- return callback(e);
38
- }
39
- }
40
- if (!settings.content) {
41
- _utils.utils.writeFile({
42
- file: settings.output,
43
- content: contentMinified.css,
44
- index
45
- });
46
- }
47
- if (callback) {
48
- return callback(null, contentMinified.css);
49
- }
50
- return contentMinified.css;
51
- };
52
-
53
- /**
54
- * Expose `minifyCssnano()`.
55
- */
56
- module.exports = minifyCssnano;