@vituum/vite-plugin-postcss 1.0.0-alpha.1 → 1.0.0-beta.1
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.
- package/README.md +12 -2
- package/index.js +12 -8
- package/package.json +2 -2
- package/types/viteUserConfig.d.ts +11 -0
package/README.md
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
<a href="https://npmjs.com/package/@vituum/vite-plugin-postcss"><img src="https://img.shields.io/npm/v/@vituum/vite-plugin-postcss.svg" alt="npm package"></a>
|
|
2
2
|
<a href="https://nodejs.org/en/about/releases/"><img src="https://img.shields.io/node/v/@vituum/vite-plugin-postcss.svg" alt="node compatility"></a>
|
|
3
3
|
|
|
4
|
-
#
|
|
4
|
+
# ⚡️🎨 VitePostCSS
|
|
5
|
+
Adds out of the box support for following PostCSS plugins:
|
|
6
|
+
* [`postcss-import`](https://www.npmjs.com/package/postcss-import)
|
|
7
|
+
* [`postcss-nesting`](https://www.npmjs.com/package/postcss-nesting)
|
|
8
|
+
* [`postcss-custom-media`](https://www.npmjs.com/package/postcss-custom-media)
|
|
9
|
+
* [`autoprefixer`](https://www.npmjs.com/package/autoprefixer)
|
|
10
|
+
|
|
11
|
+
## Basic usage
|
|
5
12
|
|
|
6
13
|
```js
|
|
7
14
|
import postcss from '@vituum/vite-plugin-postcss'
|
|
@@ -13,7 +20,10 @@ export default {
|
|
|
13
20
|
}
|
|
14
21
|
```
|
|
15
22
|
|
|
16
|
-
|
|
23
|
+
* If you want to add more PostCSS plugins, add them via [css.postcss.plugins](https://vitejs.dev/config/shared-options.html#css-postcss).
|
|
24
|
+
* If you want to use `postcss.config.cjs` add `css.postcss: process.cwd()`, PostCSS config and it's plugins will be used instead.
|
|
25
|
+
|
|
26
|
+
Read the [docs](https://vituum.dev/plugins/postcss.html) to learn more about plugin options
|
|
17
27
|
|
|
18
28
|
### Requirements
|
|
19
29
|
|
package/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { getPackageInfo, merge } from 'vituum/utils/common.js'
|
|
|
7
7
|
const { name } = getPackageInfo(import.meta.url)
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* @type {import('@vituum/vite-plugin-postcss/types/index
|
|
10
|
+
* @type {import('@vituum/vite-plugin-postcss/types/index').PluginUserConfig}
|
|
11
11
|
*/
|
|
12
12
|
const defaultOptions = {
|
|
13
13
|
import: {},
|
|
@@ -17,25 +17,29 @@ const defaultOptions = {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* @param {import('@vituum/vite-plugin-postcss/types/index
|
|
20
|
+
* @param {import('@vituum/vite-plugin-postcss/types/index').PluginUserConfig} options
|
|
21
21
|
* @returns {import('vite').Plugin}
|
|
22
22
|
*/
|
|
23
|
-
const plugin = (options) => {
|
|
23
|
+
const plugin = (options = {}) => {
|
|
24
24
|
options = merge(defaultOptions, options)
|
|
25
25
|
|
|
26
|
-
const postcssPlugins = [
|
|
26
|
+
const postcssPlugins = [
|
|
27
|
+
postcssImport(options.import),
|
|
28
|
+
postcssNesting(options.nesting),
|
|
29
|
+
postcssCustomMedia(options.customMedia),
|
|
30
|
+
autoprefixer(options.autoprefixer)
|
|
31
|
+
]
|
|
27
32
|
|
|
28
33
|
return {
|
|
29
34
|
name,
|
|
30
35
|
enforce: 'pre',
|
|
36
|
+
/** @param {import('@vituum/vite-plugin-postcss/types/viteUserConfig').ViteUserConfig} userConfig */
|
|
31
37
|
config (userConfig) {
|
|
32
|
-
|
|
33
|
-
if (!userConfig?.css?.postcss?.plugins) {
|
|
38
|
+
if (!userConfig?.css?.postcss && !userConfig?.css?.postcss?.plugins) {
|
|
34
39
|
userConfig.css = userConfig.css || {}
|
|
35
40
|
userConfig.css.postcss = userConfig.css.postcss || {}
|
|
36
41
|
userConfig.css.postcss.plugins = postcssPlugins
|
|
37
|
-
} else {
|
|
38
|
-
// @ts-ignore
|
|
42
|
+
} else if (userConfig.css.postcss.plugins) {
|
|
39
43
|
userConfig.css.postcss.plugins = postcssPlugins.concat(...userConfig.css.postcss.plugins)
|
|
40
44
|
}
|
|
41
45
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vituum/vite-plugin-postcss",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"eslint": "eslint '**/*.js' --fix"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"vituum": "^1.0.0-
|
|
11
|
+
"vituum": "^1.0.0-beta.3",
|
|
12
12
|
"lodash": "^4.17.21",
|
|
13
13
|
"autoprefixer": "^10.4.14",
|
|
14
14
|
"postcss": "^8.4.24",
|