Skip to content

Commit fb91610

Browse files
feat: added types (#142)
1 parent 092d08d commit fb91610

16 files changed

+932
-122
lines changed

README.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,15 @@ If you use your own `minify` function please read the `minify` section for handl
8787

8888
## Options
8989

90-
| Name | Type | Default | Description |
91-
| :-----------------------------------------: | :--------------------------------------------: | :----------------------------------: | :---------------------------------------------------------------------------------------------------- |
92-
| **[`test`](#test)** | `String\|RegExp\|Array<String\|RegExp>` | `/\.css(\?.*)?$/i` | Test to match files against. |
93-
| **[`include`](#include)** | `String\|RegExp\|Array<String\|RegExp>` | `undefined` | Files to include. |
94-
| **[`exclude`](#exclude)** | `String\|RegExp\|Array<String\|RegExp>` | `undefined` | Files to exclude. |
95-
| **[`parallel`](#parallel)** | `Boolean\|Number` | `true` | Enable/disable multi-process parallel running. |
96-
| **[`minify`](#minify)** | `Function\|Array<Function>` | `CssMinimizerPlugin.cssnanoMinify` | Allows to override default minify function. |
97-
| **[`minimizerOptions`](#minimizeroptions)** | `Object\|Array<Object>` | `{ preset: 'default' }` | Cssnano optimisations [options](https://cssnano.co/docs/optimisations). |
98-
| **[`processorOptions`](#processoroptions)** | `Object` | `{ to: assetName, from: assetName }` | Allows to specify option [`processoptions`](https://postcss.org/api/#processoptions) for the cssnano. |
99-
| **[`warningsFilter`](#warningsfilter)** | `Function<(warning, file, source) -> Boolean>` | `() => true` | Allow to filter css-minimizer warnings. |
90+
| Name | Type | Default | Description |
91+
| :-----------------------------------------: | :--------------------------------------------: | :--------------------------------: | :---------------------------------------------------------------------- |
92+
| **[`test`](#test)** | `String\|RegExp\|Array<String\|RegExp>` | `/\.css(\?.*)?$/i` | Test to match files against. |
93+
| **[`include`](#include)** | `String\|RegExp\|Array<String\|RegExp>` | `undefined` | Files to include. |
94+
| **[`exclude`](#exclude)** | `String\|RegExp\|Array<String\|RegExp>` | `undefined` | Files to exclude. |
95+
| **[`parallel`](#parallel)** | `Boolean\|Number` | `true` | Enable/disable multi-process parallel running. |
96+
| **[`minify`](#minify)** | `Function\|Array<Function>` | `CssMinimizerPlugin.cssnanoMinify` | Allows to override default minify function. |
97+
| **[`minimizerOptions`](#minimizeroptions)** | `Object\|Array<Object>` | `{ preset: 'default' }` | Cssnano optimisations [options](https://cssnano.co/docs/optimisations). |
98+
| **[`warningsFilter`](#warningsfilter)** | `Function<(warning, file, source) -> Boolean>` | `() => true` | Allow to filter css-minimizer warnings. |
10099

101100
### `test`
102101

@@ -341,10 +340,10 @@ module.exports = {
341340
};
342341
```
343342

344-
#### `processorOptions`
343+
##### `processorOptions` (⚠ only cssnano)
345344

346345
Type: `Object`
347-
Default: `{ to: assetName, from: assetName }`
346+
Default: `{ from: assetName }`
348347

349348
Allows filtering options [`processoptions`](https://postcss.org/api/#processoptions) for the cssnano.
350349
The `parser`,` stringifier` and `syntax` can be either a function or a string indicating the module that will be imported.

package-lock.json

Lines changed: 126 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,22 @@
1212
"url": "https://opencollective.com/webpack"
1313
},
1414
"main": "dist/cjs.js",
15+
"types": "types/cjs.d.ts",
1516
"engines": {
1617
"node": ">= 12.13.0"
1718
},
1819
"scripts": {
1920
"start": "npm run build -- -w",
2021
"clean": "del-cli dist",
2122
"prebuild": "npm run clean",
22-
"build": "cross-env NODE_ENV=production babel src -d dist --copy-files",
23+
"build:types": "tsc --declaration --emitDeclarationOnly --outDir types && prettier \"types/**/*.ts\" --write && prettier types --write",
24+
"build:code": "cross-env NODE_ENV=production babel src -d dist --copy-files",
25+
"build": "npm-run-all -p \"build:**\"",
2326
"commitlint": "commitlint --from=master",
2427
"security": "npm audit",
2528
"lint:prettier": "prettier \"{**/*,*}.{js,json,md,yml,css,ts}\" --list-different",
2629
"lint:js": "eslint --cache .",
30+
"lint:types": "tsc --pretty --noEmit",
2731
"lint": "npm-run-all -l -p \"lint:**\"",
2832
"test:only": "cross-env NODE_ENV=test jest",
2933
"test:watch": "npm run test:only -- --watch",
@@ -34,7 +38,8 @@
3438
"release": "standard-version"
3539
},
3640
"files": [
37-
"dist"
41+
"dist",
42+
"types"
3843
],
3944
"peerDependencies": {
4045
"webpack": "^5.0.0"
@@ -51,6 +56,7 @@
5156
}
5257
},
5358
"dependencies": {
59+
"@types/cssnano": "^4.0.1",
5460
"cssnano": "^5.0.6",
5561
"jest-worker": "^27.0.2",
5662
"postcss": "^8.3.5",
@@ -64,6 +70,9 @@
6470
"@babel/preset-env": "^7.15.0",
6571
"@commitlint/cli": "^15.0.0",
6672
"@commitlint/config-conventional": "^15.0.0",
73+
"@types/clean-css": "^4.2.5",
74+
"@types/csso": "^4.2.0",
75+
"@types/serialize-javascript": "^5.0.1",
6776
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
6877
"babel-jest": "^27.0.6",
6978
"clean-css": "^5.1.5",
@@ -89,6 +98,7 @@
8998
"sass-loader": "^12.1.0",
9099
"standard-version": "^9.3.0",
91100
"sugarss": "^4.0.1",
101+
"typescript": "^4.5.2",
92102
"webpack": "^5.50.0"
93103
},
94104
"keywords": [

0 commit comments

Comments
 (0)