Skip to content

Commit

Permalink
feat: added types (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Nov 23, 2021
1 parent 092d08d commit fb91610
Show file tree
Hide file tree
Showing 16 changed files with 932 additions and 122 deletions.
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,15 @@ If you use your own `minify` function please read the `minify` section for handl

## Options

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

### `test`

Expand Down Expand Up @@ -341,10 +340,10 @@ module.exports = {
};
```

#### `processorOptions`
##### `processorOptions` (⚠ only cssnano)

Type: `Object`
Default: `{ to: assetName, from: assetName }`
Default: `{ from: assetName }`

Allows filtering options [`processoptions`](https://postcss.org/api/#processoptions) for the cssnano.
The `parser`,` stringifier` and `syntax` can be either a function or a string indicating the module that will be imported.
Expand Down
132 changes: 126 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,22 @@
"url": "https://opencollective.com/webpack"
},
"main": "dist/cjs.js",
"types": "types/cjs.d.ts",
"engines": {
"node": ">= 12.13.0"
},
"scripts": {
"start": "npm run build -- -w",
"clean": "del-cli dist",
"prebuild": "npm run clean",
"build": "cross-env NODE_ENV=production babel src -d dist --copy-files",
"build:types": "tsc --declaration --emitDeclarationOnly --outDir types && prettier \"types/**/*.ts\" --write && prettier types --write",
"build:code": "cross-env NODE_ENV=production babel src -d dist --copy-files",
"build": "npm-run-all -p \"build:**\"",
"commitlint": "commitlint --from=master",
"security": "npm audit",
"lint:prettier": "prettier \"{**/*,*}.{js,json,md,yml,css,ts}\" --list-different",
"lint:js": "eslint --cache .",
"lint:types": "tsc --pretty --noEmit",
"lint": "npm-run-all -l -p \"lint:**\"",
"test:only": "cross-env NODE_ENV=test jest",
"test:watch": "npm run test:only -- --watch",
Expand All @@ -34,7 +38,8 @@
"release": "standard-version"
},
"files": [
"dist"
"dist",
"types"
],
"peerDependencies": {
"webpack": "^5.0.0"
Expand All @@ -51,6 +56,7 @@
}
},
"dependencies": {
"@types/cssnano": "^4.0.1",
"cssnano": "^5.0.6",
"jest-worker": "^27.0.2",
"postcss": "^8.3.5",
Expand All @@ -64,6 +70,9 @@
"@babel/preset-env": "^7.15.0",
"@commitlint/cli": "^15.0.0",
"@commitlint/config-conventional": "^15.0.0",
"@types/clean-css": "^4.2.5",
"@types/csso": "^4.2.0",
"@types/serialize-javascript": "^5.0.1",
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
"babel-jest": "^27.0.6",
"clean-css": "^5.1.5",
Expand All @@ -89,6 +98,7 @@
"sass-loader": "^12.1.0",
"standard-version": "^9.3.0",
"sugarss": "^4.0.1",
"typescript": "^4.5.2",
"webpack": "^5.50.0"
},
"keywords": [
Expand Down

0 comments on commit fb91610

Please sign in to comment.