Skip to content

Commit a51026e

Browse files
fix: cssnano types (#147)
1 parent b5b0cbc commit a51026e

File tree

6 files changed

+1289
-1358
lines changed

6 files changed

+1289
-1358
lines changed

package-lock.json

+1,276-1,349
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
}
5757
},
5858
"dependencies": {
59-
"@types/cssnano": "^4.0.1",
6059
"cssnano": "^5.0.6",
6160
"jest-worker": "^27.0.2",
6261
"postcss": "^8.3.5",
@@ -71,7 +70,7 @@
7170
"@commitlint/cli": "^15.0.0",
7271
"@commitlint/config-conventional": "^15.0.0",
7372
"@types/clean-css": "^4.2.5",
74-
"@types/csso": "^4.2.0",
73+
"@types/csso": "^5.0.0",
7574
"@types/serialize-javascript": "^5.0.1",
7675
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
7776
"babel-jest": "^27.0.6",

src/index.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,18 @@ const { minify } = require("./minify");
2222
/** @typedef {import("webpack").WebpackError} WebpackError */
2323
/** @typedef {import("jest-worker").Worker} JestWorker */
2424
/** @typedef {import("source-map").RawSourceMap} RawSourceMap */
25-
/** @typedef {import("cssnano").CssNanoOptions} CssNanoOptions */
2625
/** @typedef {import("webpack").Asset} Asset */
2726
/** @typedef {import("postcss").ProcessOptions} ProcessOptions */
2827
/** @typedef {import("postcss").Syntax} Syntax */
2928
/** @typedef {import("postcss").Parser} Parser */
3029
/** @typedef {import("postcss").Stringifier} Stringifier */
3130

31+
/**
32+
* @typedef {Object} CssNanoOptions
33+
* @property {string} [configFile]
34+
* @property {[string, object] | string | undefined} [preset]
35+
*/
36+
3237
/** @typedef {Error & { plugin?: string, text?: string, source?: string } | string} Warning */
3338

3439
/**

src/utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
/** @typedef {import("./index.js").CustomOptions} CustomOptions */
66
/** @typedef {import("postcss").ProcessOptions} ProcessOptions */
77
/** @typedef {import("postcss").Postcss} Postcss */
8-
/** @typedef {import("cssnano")} CssNano */
98

109
const notSettled = Symbol(`not-settled`);
1110

@@ -167,6 +166,7 @@ async function cssnanoMinify(
167166
/** @type {Postcss} */
168167
// eslint-disable-next-line global-require
169168
const postcss = require("postcss").default;
169+
// @ts-ignore
170170
// eslint-disable-next-line global-require
171171
const cssnano = require("cssnano");
172172
// @ts-ignore

types/index.d.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ declare namespace CssMinimizerPlugin {
7474
WebpackError,
7575
JestWorker,
7676
RawSourceMap,
77-
CssNanoOptions,
7877
Asset,
7978
ProcessOptions,
8079
Syntax,
8180
Parser,
8281
Stringifier,
82+
CssNanoOptions,
8383
Warning,
8484
WarningObject,
8585
ErrorObject,
@@ -133,12 +133,15 @@ type Compilation = import("webpack").Compilation;
133133
type WebpackError = import("webpack").WebpackError;
134134
type JestWorker = import("jest-worker").Worker;
135135
type RawSourceMap = import("source-map").RawSourceMap;
136-
type CssNanoOptions = import("cssnano").CssNanoOptions;
137136
type Asset = import("webpack").Asset;
138137
type ProcessOptions = import("postcss").ProcessOptions;
139138
type Syntax = import("postcss").Syntax;
140139
type Parser = import("postcss").Parser;
141140
type Stringifier = import("postcss").Stringifier;
141+
type CssNanoOptions = {
142+
configFile?: string | undefined;
143+
preset?: [string, object] | string | undefined;
144+
};
142145
type Warning =
143146
| (Error & {
144147
plugin?: string;

types/utils.d.ts

-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ export type MinimizedResult = import("./index.js").MinimizedResult;
66
export type CustomOptions = import("./index.js").CustomOptions;
77
export type ProcessOptions = import("postcss").ProcessOptions;
88
export type Postcss = import("postcss").Postcss;
9-
export type CssNano = import("cssnano/node_modules/postcss").Plugin<
10-
import("cssnano").CssNanoOptions
11-
>;
129
/**
1310
* @template T
1411
* @typedef {() => Promise<T>} Task

0 commit comments

Comments
 (0)