@web-baseline/nuxt-css-layer 0.1.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.
- package/LICENSE +21 -0
- package/README.md +54 -0
- package/README.zh-CN.md +54 -0
- package/dist/module.cjs +5 -0
- package/dist/module.d.mts +14 -0
- package/dist/module.d.ts +14 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +57 -0
- package/dist/types.d.mts +16 -0
- package/dist/types.d.ts +16 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Web baseline
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Nuxt CSS layer (@web-baseline/nuxt-css-layer)
|
|
2
|
+
|
|
3
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
4
|
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
5
|
+
[![License][license-src]][license-href]
|
|
6
|
+
[![Nuxt][nuxt-src]][nuxt-href]
|
|
7
|
+
|
|
8
|
+
_✨ Use css cascade layers in Nuxt ✨_
|
|
9
|
+
|
|
10
|
+
- [✨ Release Notes](/CHANGELOG.md)
|
|
11
|
+
|
|
12
|
+
**English** | [简体中文](./README.zh-CN.md)
|
|
13
|
+
|
|
14
|
+
## Features
|
|
15
|
+
|
|
16
|
+
- Add cascading layers to CSS files ( By [@web-baseline/postcss-wrap-up-layer](https://github.com/web-baseline/postcss-wrap-up-layer) )
|
|
17
|
+
- Allow adding cascading layer to style blocks in Vue SFC ( By [@web-baseline/vite-plugin-vue-style-layer](https://github.com/web-baseline/vite-plugin-vue-style-layer) )
|
|
18
|
+
- CSS cascading layer sorting
|
|
19
|
+
|
|
20
|
+
## Quick Setup
|
|
21
|
+
|
|
22
|
+
Install the module to your Nuxt application with one command:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npx nuxi module add @web-baseline/nuxt-css-layer
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
That's it! You can now use css cascade layers in your Nuxt app ✨
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Options
|
|
32
|
+
|
|
33
|
+
| Option | Description | Type | Default |
|
|
34
|
+
| ------------------ | ---------------------------------------------------------------------------------------------------------------- | --------------------------------- | ----------- |
|
|
35
|
+
| sfc | Is SFC processing enabled | `boolean` | `true` |
|
|
36
|
+
| sfcIncludes | SFC files (refer to [`@web-baseline/vite-plugin-vue-style-layer`](https://github.com/web-baseline/vite-plugin-vue-style-layer/tree/main?tab=readme-ov-file#options)) | -- | -- |
|
|
37
|
+
| rules | CSS file rules (refer to [`@web-baseline/postcss-wrap-up-layer`](https://github.com/web-baseline/postcss-wrap-up-layer?tab=readme-ov-file#options-type)) | -- | -- |
|
|
38
|
+
| ignoreOnlyComments | Ignore files that only contain comments (refer to [`@web-baseline/postcss-wrap-up-layer`](https://github.com/web-baseline/postcss-wrap-up-layer?tab=readme-ov-file#options-type)) | -- | -- |
|
|
39
|
+
| cssLayerOrder | Cascade layer sorting | `string \| string[] \| undefined` | `undefined` |
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
<!-- Badges -->
|
|
44
|
+
[npm-version-src]: https://img.shields.io/npm/v/@web-baseline/nuxt-css-layer/latest.svg?style=flat&colorA=020420&colorB=00DC82
|
|
45
|
+
[npm-version-href]: https://npmjs.com/package/@web-baseline/nuxt-css-layer
|
|
46
|
+
|
|
47
|
+
[npm-downloads-src]: https://img.shields.io/npm/dm/@web-baseline/nuxt-css-layer.svg?style=flat&colorA=020420&colorB=00DC82
|
|
48
|
+
[npm-downloads-href]: https://npmjs.com/package/@web-baseline/nuxt-css-layer
|
|
49
|
+
|
|
50
|
+
[license-src]: https://img.shields.io/npm/l/@web-baseline/nuxt-css-layer.svg?style=flat&colorA=020420&colorB=00DC82
|
|
51
|
+
[license-href]: https://npmjs.com/package/@web-baseline/nuxt-css-layer
|
|
52
|
+
|
|
53
|
+
[nuxt-src]: https://img.shields.io/badge/Nuxt-020420?logo=nuxt.js
|
|
54
|
+
[nuxt-href]: https://nuxt.com
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Nuxt CSS layer (@web-baseline/nuxt-css-layer)
|
|
2
|
+
|
|
3
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
4
|
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
5
|
+
[![License][license-src]][license-href]
|
|
6
|
+
[![Nuxt][nuxt-src]][nuxt-href]
|
|
7
|
+
|
|
8
|
+
_✨ 在 Nuxt 中使用 CSS 级联层 ✨_
|
|
9
|
+
|
|
10
|
+
- [✨ Release Notes](/CHANGELOG.md)
|
|
11
|
+
|
|
12
|
+
[English](./README.md) | **简体中文**
|
|
13
|
+
|
|
14
|
+
## 特性
|
|
15
|
+
|
|
16
|
+
- 为 CSS 文件添加级联层(使用 [@web-baseline/postcss-wrap-up-layer](https://github.com/web-baseline/postcss-wrap-up-layer))
|
|
17
|
+
- 允许 Vue SFC 的 `<style>` 块设置 CSS 级联层 (使用 [@web-baseline/vite-plugin-vue-style-layer](https://github.com/web-baseline/postcss-wrap-up-layer/blob/main/README.zh-CN.md))
|
|
18
|
+
- CSS 级联层排序
|
|
19
|
+
|
|
20
|
+
## 快速开始
|
|
21
|
+
|
|
22
|
+
使用一个命令将模块安装到 Nuxt 应用程序中:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npx nuxi module add @web-baseline/nuxt-css-layer
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
就是这样!现在,您可以在 Nuxt 应用程序中使用 CSS 级联层 ✨
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### 配置
|
|
32
|
+
|
|
33
|
+
| 配置项 | 描述 | 类型 | 默认值 |
|
|
34
|
+
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | ----------- |
|
|
35
|
+
| sfc | 是否开启单文件组件处理 | `boolean` | `true` |
|
|
36
|
+
| sfcIncludes | 单文件组件处理包含的文件(参考[`@web-baseline/vite-plugin-vue-style-layer`](https://github.com/web-baseline/vite-plugin-vue-style-layer/tree/main?tab=readme-ov-file#options)) | -- | -- |
|
|
37
|
+
| rules | CSS文件处理规则(参考[`@web-baseline/postcss-wrap-up-layer`](https://github.com/web-baseline/postcss-wrap-up-layer/blob/main/README.zh-CN.md#%E9%80%89%E9%A1%B9%E7%B1%BB%E5%9E%8B)) | -- | -- |
|
|
38
|
+
| ignoreOnlyComments | 是否忽略仅包含注释的文件(参考[`@web-baseline/postcss-wrap-up-layer`](https://github.com/web-baseline/postcss-wrap-up-layer/blob/main/README.zh-CN.md#%E9%80%89%E9%A1%B9%E7%B1%BB%E5%9E%8B)) | -- | -- |
|
|
39
|
+
| cssLayerOrder | 级联层排序 | `string \| string[] \| undefined` | `undefined` |
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
<!-- Badges -->
|
|
44
|
+
[npm-version-src]: https://img.shields.io/npm/v/@web-baseline/nuxt-css-layer/latest.svg?style=flat&colorA=020420&colorB=00DC82
|
|
45
|
+
[npm-version-href]: https://npmjs.com/package/@web-baseline/nuxt-css-layer
|
|
46
|
+
|
|
47
|
+
[npm-downloads-src]: https://img.shields.io/npm/dm/@web-baseline/nuxt-css-layer.svg?style=flat&colorA=020420&colorB=00DC82
|
|
48
|
+
[npm-downloads-href]: https://npmjs.com/package/@web-baseline/nuxt-css-layer
|
|
49
|
+
|
|
50
|
+
[license-src]: https://img.shields.io/npm/l/@web-baseline/nuxt-css-layer.svg?style=flat&colorA=020420&colorB=00DC82
|
|
51
|
+
[license-href]: https://npmjs.com/package/@web-baseline/nuxt-css-layer
|
|
52
|
+
|
|
53
|
+
[nuxt-src]: https://img.shields.io/badge/Nuxt-020420?logo=nuxt.js
|
|
54
|
+
[nuxt-href]: https://nuxt.com
|
package/dist/module.cjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { PluginOptions as PluginOptions$1 } from '@web-baseline/postcss-wrap-up-layer';
|
|
3
|
+
import { PluginOptions } from '@web-baseline/vite-plugin-vue-style-layer';
|
|
4
|
+
|
|
5
|
+
interface ModuleOptions {
|
|
6
|
+
sfc: boolean;
|
|
7
|
+
sfcIncludes?: PluginOptions['includes'];
|
|
8
|
+
rules: PluginOptions$1['rules'];
|
|
9
|
+
ignoreOnlyComments?: PluginOptions$1['ignoreOnlyComments'];
|
|
10
|
+
cssLayerOrder?: string | string[];
|
|
11
|
+
}
|
|
12
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
|
|
13
|
+
|
|
14
|
+
export { type ModuleOptions, _default as default };
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { PluginOptions as PluginOptions$1 } from '@web-baseline/postcss-wrap-up-layer';
|
|
3
|
+
import { PluginOptions } from '@web-baseline/vite-plugin-vue-style-layer';
|
|
4
|
+
|
|
5
|
+
interface ModuleOptions {
|
|
6
|
+
sfc: boolean;
|
|
7
|
+
sfcIncludes?: PluginOptions['includes'];
|
|
8
|
+
rules: PluginOptions$1['rules'];
|
|
9
|
+
ignoreOnlyComments?: PluginOptions$1['ignoreOnlyComments'];
|
|
10
|
+
cssLayerOrder?: string | string[];
|
|
11
|
+
}
|
|
12
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
|
|
13
|
+
|
|
14
|
+
export { type ModuleOptions, _default as default };
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { defineNuxtModule, addVitePlugin, addTemplate, addServerPlugin } from '@nuxt/kit';
|
|
2
|
+
import WrapUpLayer from '@web-baseline/postcss-wrap-up-layer';
|
|
3
|
+
import VueStyleLayer from '@web-baseline/vite-plugin-vue-style-layer';
|
|
4
|
+
|
|
5
|
+
const module = defineNuxtModule({
|
|
6
|
+
meta: {
|
|
7
|
+
name: "nuxt-css-layer",
|
|
8
|
+
configKey: "cssLayer"
|
|
9
|
+
},
|
|
10
|
+
defaults: {
|
|
11
|
+
sfc: true,
|
|
12
|
+
rules: []
|
|
13
|
+
},
|
|
14
|
+
setup(options) {
|
|
15
|
+
if (options.rules.length > 0) {
|
|
16
|
+
addVitePlugin({
|
|
17
|
+
name: "vite-plugin-nuxt-css-layer--postcss",
|
|
18
|
+
config: () => ({
|
|
19
|
+
css: {
|
|
20
|
+
postcss: {
|
|
21
|
+
plugins: [
|
|
22
|
+
WrapUpLayer({
|
|
23
|
+
rules: options.rules,
|
|
24
|
+
ignoreOnlyComments: options.ignoreOnlyComments
|
|
25
|
+
})
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (options.sfc) {
|
|
33
|
+
addVitePlugin(VueStyleLayer({
|
|
34
|
+
includes: options.sfcIncludes
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
if (options.cssLayerOrder) {
|
|
38
|
+
const plugin = addTemplate({
|
|
39
|
+
filename: "nuxt-css-layer/css-layers.ts",
|
|
40
|
+
getContents: () => `import { defineNitroPlugin } from 'nitropack/runtime';
|
|
41
|
+
|
|
42
|
+
export const layers = ${Array.isArray(options.cssLayerOrder) ? JSON.stringify(options.cssLayerOrder) : JSON.stringify(options.cssLayerOrder.split(",").map((layer) => layer.trim()).filter((layer) => layer.length > 0))};
|
|
43
|
+
|
|
44
|
+
export default defineNitroPlugin((nitro) => {
|
|
45
|
+
nitro.hooks.hook('render:html', (html) => {
|
|
46
|
+
html.head.unshift(\`<style>@layer \${layers.join(', ')};</style>\`);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
`,
|
|
50
|
+
write: true
|
|
51
|
+
});
|
|
52
|
+
addServerPlugin(plugin.dst);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export { module as default };
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
import type { ModuleOptions } from './module.js'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
declare module '@nuxt/schema' {
|
|
6
|
+
interface NuxtConfig { ['cssLayer']?: Partial<ModuleOptions> }
|
|
7
|
+
interface NuxtOptions { ['cssLayer']?: ModuleOptions }
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare module 'nuxt/schema' {
|
|
11
|
+
interface NuxtConfig { ['cssLayer']?: Partial<ModuleOptions> }
|
|
12
|
+
interface NuxtOptions { ['cssLayer']?: ModuleOptions }
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export type { ModuleOptions, default } from './module.js'
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
import type { ModuleOptions } from './module'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
declare module '@nuxt/schema' {
|
|
6
|
+
interface NuxtConfig { ['cssLayer']?: Partial<ModuleOptions> }
|
|
7
|
+
interface NuxtOptions { ['cssLayer']?: ModuleOptions }
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare module 'nuxt/schema' {
|
|
11
|
+
interface NuxtConfig { ['cssLayer']?: Partial<ModuleOptions> }
|
|
12
|
+
interface NuxtOptions { ['cssLayer']?: ModuleOptions }
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export type { ModuleOptions, default } from './module'
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@web-baseline/nuxt-css-layer",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Use css cascade layers in Nuxt",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/types.d.ts",
|
|
10
|
+
"import": "./dist/module.mjs",
|
|
11
|
+
"require": "./dist/module.cjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"main": "./dist/module.cjs",
|
|
15
|
+
"types": "./dist/types.d.ts",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"css",
|
|
24
|
+
"css cascade layer",
|
|
25
|
+
"vue",
|
|
26
|
+
"nuxt",
|
|
27
|
+
"nuxt-module"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"prepack": "nuxt-module-build build",
|
|
31
|
+
"dev": "nuxi dev playground",
|
|
32
|
+
"dev:build": "nuxi build playground",
|
|
33
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
34
|
+
"release": "npm run build && changelogen --release && npm publish && git push --follow-tags",
|
|
35
|
+
"build": "npm run dev:prepare && npm run lint && npm run test && npm run prepack",
|
|
36
|
+
"lint": "eslint .",
|
|
37
|
+
"test": "vitest run",
|
|
38
|
+
"test:watch": "vitest watch",
|
|
39
|
+
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
|
|
40
|
+
},
|
|
41
|
+
"author": "TM-SunnyDay <sunnyday@chongying.studio> (https://github.com/TM-SunnyDay/)",
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "git+https://github.com/web-baseline/nuxt-css-layer"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@nuxt/kit": "^3.11.2",
|
|
48
|
+
"@web-baseline/postcss-wrap-up-layer": "^0.1.0",
|
|
49
|
+
"@web-baseline/vite-plugin-vue-style-layer": "^0.1.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@element-plus/nuxt": "^1.0.9",
|
|
53
|
+
"@nuxt/devtools": "^1.2.0",
|
|
54
|
+
"@nuxt/eslint-config": "^0.3.10",
|
|
55
|
+
"@nuxt/module-builder": "^0.6.0",
|
|
56
|
+
"@nuxt/schema": "^3.11.2",
|
|
57
|
+
"@nuxt/test-utils": "^3.12.1",
|
|
58
|
+
"@types/node": "^20.12.11",
|
|
59
|
+
"changelogen": "^0.5.5",
|
|
60
|
+
"element-plus": "^2.7.3",
|
|
61
|
+
"eslint": "^9.2.0",
|
|
62
|
+
"nuxt": "^3.12.2",
|
|
63
|
+
"typescript": "latest",
|
|
64
|
+
"vitest": "^1.6.0",
|
|
65
|
+
"vue-tsc": "^2.0.16"
|
|
66
|
+
}
|
|
67
|
+
}
|