@sylphx/silk-nuxt 1.0.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 +148 -0
- package/dist/module.cjs +5 -0
- package/dist/module.d.mts +40 -0
- package/dist/module.d.ts +40 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +60 -0
- package/dist/runtime/plugin.d.ts +6 -0
- package/dist/runtime/plugin.js +3 -0
- package/dist/types.d.mts +7 -0
- package/dist/types.d.ts +7 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# @sylphx/silk-nuxt
|
|
2
|
+
|
|
3
|
+
Nuxt 3 module for [Silk](https://github.com/sylphxltd/silk) - Zero-codegen, zero-runtime CSS-in-TypeScript.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- ✅ **Zero-codegen**: No manual `generate` commands
|
|
8
|
+
- ✅ **Zero-runtime**: CSS generated at build time
|
|
9
|
+
- ✅ **Auto-import**: Automatic CSS injection
|
|
10
|
+
- ✅ **HMR**: Hot Module Replacement support
|
|
11
|
+
- ✅ **Type-safe**: Full TypeScript support
|
|
12
|
+
- ✅ **Framework integration**: Works with Nuxt's Vite pipeline
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @sylphx/silk @sylphx/silk-nuxt
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### 1. Add module to `nuxt.config.ts`
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
// nuxt.config.ts
|
|
26
|
+
export default defineNuxtConfig({
|
|
27
|
+
modules: ['@sylphx/silk-nuxt']
|
|
28
|
+
})
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### 2. Use in your components
|
|
32
|
+
|
|
33
|
+
```vue
|
|
34
|
+
<!-- pages/index.vue -->
|
|
35
|
+
<script setup lang="ts">
|
|
36
|
+
import { createStyleSystem } from '@sylphx/silk'
|
|
37
|
+
|
|
38
|
+
const { css } = createStyleSystem({})
|
|
39
|
+
|
|
40
|
+
const styles = {
|
|
41
|
+
container: css({
|
|
42
|
+
display: 'flex',
|
|
43
|
+
flexDirection: 'column',
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
padding: '2rem',
|
|
46
|
+
backgroundColor: '#f5f5f5'
|
|
47
|
+
} as any),
|
|
48
|
+
title: css({
|
|
49
|
+
fontSize: '2.5rem',
|
|
50
|
+
fontWeight: 'bold',
|
|
51
|
+
color: '#00DC82'
|
|
52
|
+
} as any)
|
|
53
|
+
}
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<template>
|
|
57
|
+
<div :class="styles.container.className">
|
|
58
|
+
<h1 :class="styles.title.className">
|
|
59
|
+
Nuxt + Silk ✅
|
|
60
|
+
</h1>
|
|
61
|
+
</div>
|
|
62
|
+
</template>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
That's it! No need to manually import `silk.css` - the module handles it automatically.
|
|
66
|
+
|
|
67
|
+
## Configuration
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
// nuxt.config.ts
|
|
71
|
+
export default defineNuxtConfig({
|
|
72
|
+
modules: ['@sylphx/silk-nuxt'],
|
|
73
|
+
|
|
74
|
+
silk: {
|
|
75
|
+
// Source directory to scan for css() calls
|
|
76
|
+
// Default: Nuxt's srcDir
|
|
77
|
+
srcDir: './app',
|
|
78
|
+
|
|
79
|
+
// Virtual module ID
|
|
80
|
+
// Default: 'silk.css'
|
|
81
|
+
virtualModuleId: 'silk.css',
|
|
82
|
+
|
|
83
|
+
// Enable debug logging
|
|
84
|
+
// Default: false
|
|
85
|
+
debug: true,
|
|
86
|
+
|
|
87
|
+
// Enable CSS minification
|
|
88
|
+
// Default: true in production, false in dev
|
|
89
|
+
minify: true,
|
|
90
|
+
|
|
91
|
+
// Auto-import silk.css globally
|
|
92
|
+
// Default: true
|
|
93
|
+
autoImport: true
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Manual Import (if autoImport: false)
|
|
99
|
+
|
|
100
|
+
```vue
|
|
101
|
+
<!-- app.vue -->
|
|
102
|
+
<script setup>
|
|
103
|
+
import 'silk.css'
|
|
104
|
+
</script>
|
|
105
|
+
|
|
106
|
+
<template>
|
|
107
|
+
<NuxtPage />
|
|
108
|
+
</template>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## How it works
|
|
112
|
+
|
|
113
|
+
1. The module wraps `@sylphx/silk-vite-plugin`
|
|
114
|
+
2. Scans your source files for `css()` calls at build time
|
|
115
|
+
3. Generates optimized CSS with lightningcss-wasm
|
|
116
|
+
4. Creates a virtual module that Nuxt's Vite pipeline processes
|
|
117
|
+
5. Auto-imports the CSS (if `autoImport: true`)
|
|
118
|
+
6. CSS flows through Nuxt's PostCSS, minification, and bundling
|
|
119
|
+
|
|
120
|
+
## Benefits over manual Vite plugin
|
|
121
|
+
|
|
122
|
+
**With `@sylphx/silk-nuxt`:**
|
|
123
|
+
```typescript
|
|
124
|
+
export default defineNuxtConfig({
|
|
125
|
+
modules: ['@sylphx/silk-nuxt']
|
|
126
|
+
})
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Without (manual Vite plugin):**
|
|
130
|
+
```typescript
|
|
131
|
+
import silk from '@sylphx/silk-vite-plugin'
|
|
132
|
+
|
|
133
|
+
export default defineNuxtConfig({
|
|
134
|
+
vite: {
|
|
135
|
+
plugins: [silk()]
|
|
136
|
+
}
|
|
137
|
+
})
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
The Nuxt module provides:
|
|
141
|
+
- ✅ Simpler configuration
|
|
142
|
+
- ✅ Auto-import support
|
|
143
|
+
- ✅ Nuxt-specific optimizations
|
|
144
|
+
- ✅ Better integration with Nuxt's build system
|
|
145
|
+
|
|
146
|
+
## License
|
|
147
|
+
|
|
148
|
+
MIT © SylphX Ltd
|
package/dist/module.cjs
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @sylphx/silk-nuxt
|
|
3
|
+
* Nuxt 3 module for Silk - Zero-codegen CSS-in-TypeScript
|
|
4
|
+
*
|
|
5
|
+
* Architecture:
|
|
6
|
+
* - Wraps @sylphx/silk-vite-plugin for Nuxt's Vite builds
|
|
7
|
+
* - Auto-imports silk.css in app.vue
|
|
8
|
+
* - Handles client, server, and nitro builds
|
|
9
|
+
*/
|
|
10
|
+
interface ModuleOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Source directory to scan for css() calls
|
|
13
|
+
* @default './src' or Nuxt's srcDir
|
|
14
|
+
*/
|
|
15
|
+
srcDir?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Virtual module ID
|
|
18
|
+
* @default 'silk.css'
|
|
19
|
+
*/
|
|
20
|
+
virtualModuleId?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Enable debug logging
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
debug?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Enable CSS minification
|
|
28
|
+
* @default true in production
|
|
29
|
+
*/
|
|
30
|
+
minify?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Auto-import silk.css globally
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
autoImport?: boolean;
|
|
36
|
+
}
|
|
37
|
+
declare const _default: any;
|
|
38
|
+
|
|
39
|
+
export { _default as default };
|
|
40
|
+
export type { ModuleOptions };
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @sylphx/silk-nuxt
|
|
3
|
+
* Nuxt 3 module for Silk - Zero-codegen CSS-in-TypeScript
|
|
4
|
+
*
|
|
5
|
+
* Architecture:
|
|
6
|
+
* - Wraps @sylphx/silk-vite-plugin for Nuxt's Vite builds
|
|
7
|
+
* - Auto-imports silk.css in app.vue
|
|
8
|
+
* - Handles client, server, and nitro builds
|
|
9
|
+
*/
|
|
10
|
+
interface ModuleOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Source directory to scan for css() calls
|
|
13
|
+
* @default './src' or Nuxt's srcDir
|
|
14
|
+
*/
|
|
15
|
+
srcDir?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Virtual module ID
|
|
18
|
+
* @default 'silk.css'
|
|
19
|
+
*/
|
|
20
|
+
virtualModuleId?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Enable debug logging
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
debug?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Enable CSS minification
|
|
28
|
+
* @default true in production
|
|
29
|
+
*/
|
|
30
|
+
minify?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Auto-import silk.css globally
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
autoImport?: boolean;
|
|
36
|
+
}
|
|
37
|
+
declare const _default: any;
|
|
38
|
+
|
|
39
|
+
export { _default as default };
|
|
40
|
+
export type { ModuleOptions };
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { defineNuxtModule, createResolver, addPlugin } from '@nuxt/kit';
|
|
2
|
+
import silkVitePlugin from '@sylphx/silk-vite-plugin';
|
|
3
|
+
|
|
4
|
+
const module = defineNuxtModule({
|
|
5
|
+
meta: {
|
|
6
|
+
name: "@sylphx/silk-nuxt",
|
|
7
|
+
configKey: "silk",
|
|
8
|
+
compatibility: {
|
|
9
|
+
nuxt: "^3.0.0"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
defaults: {
|
|
13
|
+
srcDir: void 0,
|
|
14
|
+
// Will use Nuxt's srcDir
|
|
15
|
+
virtualModuleId: "silk.css",
|
|
16
|
+
debug: false,
|
|
17
|
+
minify: void 0,
|
|
18
|
+
// Will use production mode detection
|
|
19
|
+
autoImport: true
|
|
20
|
+
},
|
|
21
|
+
setup(options, nuxt) {
|
|
22
|
+
const resolver = createResolver(import.meta.url);
|
|
23
|
+
const srcDir = options.srcDir || nuxt.options.srcDir;
|
|
24
|
+
if (options.debug) {
|
|
25
|
+
console.log("[Silk Nuxt] Module loaded");
|
|
26
|
+
console.log("[Silk Nuxt] Source directory:", srcDir);
|
|
27
|
+
}
|
|
28
|
+
nuxt.hook("vite:extend", ({ config }) => {
|
|
29
|
+
config.plugins = config.plugins || [];
|
|
30
|
+
config.plugins.push(
|
|
31
|
+
silkVitePlugin({
|
|
32
|
+
srcDir,
|
|
33
|
+
virtualModuleId: options.virtualModuleId,
|
|
34
|
+
debug: options.debug,
|
|
35
|
+
minify: options.minify ?? nuxt.options.dev === false
|
|
36
|
+
})
|
|
37
|
+
);
|
|
38
|
+
if (options.debug) {
|
|
39
|
+
console.log("[Silk Nuxt] Vite plugin added");
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
if (options.autoImport) {
|
|
43
|
+
addPlugin({
|
|
44
|
+
src: resolver.resolve("./runtime/plugin"),
|
|
45
|
+
mode: "client"
|
|
46
|
+
// Only inject on client side
|
|
47
|
+
});
|
|
48
|
+
if (options.debug) {
|
|
49
|
+
console.log("[Silk Nuxt] Auto-import enabled");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (options.debug) {
|
|
53
|
+
nuxt.hook("ready", () => {
|
|
54
|
+
console.log("[Silk Nuxt] \u2705 Module ready");
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export { module as default };
|
package/dist/types.d.mts
ADDED
package/dist/types.d.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sylphx/silk-nuxt",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Nuxt 3 module for Silk - Zero-codegen CSS-in-TypeScript",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"silk",
|
|
7
|
+
"nuxt",
|
|
8
|
+
"nuxt-module",
|
|
9
|
+
"css-in-js",
|
|
10
|
+
"typescript",
|
|
11
|
+
"zero-codegen"
|
|
12
|
+
],
|
|
13
|
+
"author": "SylphX Ltd",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"homepage": "https://sylphx.com",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/sylphxltd/silk.git",
|
|
19
|
+
"directory": "packages/nuxt-module"
|
|
20
|
+
},
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/sylphxltd/silk/issues"
|
|
23
|
+
},
|
|
24
|
+
"type": "module",
|
|
25
|
+
"main": "./dist/module.mjs",
|
|
26
|
+
"types": "./dist/module.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"import": "./dist/module.mjs",
|
|
30
|
+
"types": "./dist/module.d.ts"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"README.md",
|
|
36
|
+
"LICENSE"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "nuxt-module-build",
|
|
40
|
+
"dev": "nuxt-module-build --stub",
|
|
41
|
+
"prepublishOnly": "bun run build"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@sylphx/silk-vite-plugin": "workspace:*",
|
|
45
|
+
"@nuxt/kit": "^3.13.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@nuxt/module-builder": "^0.8.0",
|
|
49
|
+
"@nuxt/schema": "^3.13.0",
|
|
50
|
+
"nuxt": "^3.13.0"
|
|
51
|
+
},
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public"
|
|
54
|
+
}
|
|
55
|
+
}
|