@plumeria/unplugin 10.5.3
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 +159 -0
- package/dist/bun.d.ts +3 -0
- package/dist/bun.js +5 -0
- package/dist/bun.mjs +3 -0
- package/dist/core.d.ts +9 -0
- package/dist/core.js +1298 -0
- package/dist/core.mjs +1261 -0
- package/dist/disk-css.d.ts +4 -0
- package/dist/disk-css.js +104 -0
- package/dist/disk-css.mjs +65 -0
- package/dist/esbuild.d.ts +3 -0
- package/dist/esbuild.js +5 -0
- package/dist/esbuild.mjs +3 -0
- package/dist/farm.d.ts +3 -0
- package/dist/farm.js +111 -0
- package/dist/farm.mjs +76 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +38 -0
- package/dist/index.mjs +24 -0
- package/dist/rolldown.d.ts +3 -0
- package/dist/rolldown.js +5 -0
- package/dist/rolldown.mjs +3 -0
- package/dist/rollup.d.ts +3 -0
- package/dist/rollup.js +5 -0
- package/dist/rollup.mjs +3 -0
- package/dist/rspack.d.ts +3 -0
- package/dist/rspack.js +8 -0
- package/dist/rspack.mjs +6 -0
- package/dist/unloader.d.ts +3 -0
- package/dist/unloader.js +5 -0
- package/dist/unloader.mjs +3 -0
- package/dist/vite.d.ts +7 -0
- package/dist/vite.js +143 -0
- package/dist/vite.mjs +108 -0
- package/dist/webpack.d.ts +4 -0
- package/dist/webpack.js +167 -0
- package/dist/webpack.mjs +131 -0
- package/package.json +105 -0
- package/zero-virtual.css +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) zss-in-js contributer
|
|
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,159 @@
|
|
|
1
|
+
# @plumeria/unplugin
|
|
2
|
+
|
|
3
|
+
This is a universal bundler plugin for Plumeria. Built on [unplugin](https://github.com/unjs/unplugin), it provides plugins for all major frontend build tools from a single codebase.
|
|
4
|
+
|
|
5
|
+
It completely eliminates runtime overhead by parsing Plumeria's Zero-Runtime CSS-in-JS at build time and extracting it as a virtual CSS module.
|
|
6
|
+
|
|
7
|
+
## Compatible Bundlers
|
|
8
|
+
|
|
9
|
+
- [Vite](https://vitejs.dev/)
|
|
10
|
+
- [Webpack](https://webpack.js.org/)
|
|
11
|
+
- [Rspack](https://www.rspack.dev/)
|
|
12
|
+
- [Farm](https://farmfe.org/)
|
|
13
|
+
- [Esbuild](https://esbuild.github.io/)
|
|
14
|
+
- [Rollup](https://rollupjs.org/)
|
|
15
|
+
- [Rolldown](https://rolldown.rs/)
|
|
16
|
+
- [Bun](https://bun.sh/)
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install -D @plumeria/unplugin
|
|
22
|
+
# or
|
|
23
|
+
yarn add -D @plumeria/unplugin
|
|
24
|
+
# or
|
|
25
|
+
pnpm add -D @plumeria/unplugin
|
|
26
|
+
# Alternatively,
|
|
27
|
+
bun add -D @plumeria/unplugin
|
|
28
|
+
```
|
|
29
|
+
## How to Use
|
|
30
|
+
|
|
31
|
+
Import `@plumeria/unplugin` in the configuration file of each bundler, and register it as a plugin by calling the bundler-specific method (`vite()`, `webpack()`, etc.).
|
|
32
|
+
|
|
33
|
+
### Vite
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
//vite.config.js
|
|
37
|
+
import { defineConfig } from 'vite';
|
|
38
|
+
import plumeria from '@plumeria/unplugin';
|
|
39
|
+
|
|
40
|
+
export default defineConfig({
|
|
41
|
+
plugins: [
|
|
42
|
+
plumeria.vite(),
|
|
43
|
+
],
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Webpack
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
// webpack.config.js
|
|
51
|
+
import plumeria from '@plumeria/unplugin';
|
|
52
|
+
|
|
53
|
+
export default {
|
|
54
|
+
plugins: [
|
|
55
|
+
plumeria.webpack(),
|
|
56
|
+
],
|
|
57
|
+
};
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Rspack
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
// rspack.config.js
|
|
64
|
+
import plumeria from '@plumeria/unplugin';
|
|
65
|
+
|
|
66
|
+
export default {
|
|
67
|
+
plugins: [
|
|
68
|
+
plumeria.rspack(),
|
|
69
|
+
],
|
|
70
|
+
};
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Farm
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
// farm.config.js
|
|
77
|
+
import { defineConfig } from '@farmfe/core';
|
|
78
|
+
import plumeria from '@plumeria/unplugin';
|
|
79
|
+
|
|
80
|
+
export default defineConfig({
|
|
81
|
+
plugins: [
|
|
82
|
+
plumeria.farm({ devEmitToDisk: true }),
|
|
83
|
+
],
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Esbuild
|
|
88
|
+
|
|
89
|
+
```js
|
|
90
|
+
// build.js
|
|
91
|
+
import { build } from 'esbuild';
|
|
92
|
+
import plumeria from '@plumeria/unplugin';
|
|
93
|
+
|
|
94
|
+
build({
|
|
95
|
+
entryPoints: ['src/index.tsx'],
|
|
96
|
+
bundle: true,
|
|
97
|
+
outfile: 'dist/out.js',
|
|
98
|
+
plugins: [
|
|
99
|
+
plumeria.esbuild(),
|
|
100
|
+
],
|
|
101
|
+
}).catch(() => process.exit(1));
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Rollup
|
|
105
|
+
```js
|
|
106
|
+
// rollup.config.js
|
|
107
|
+
import plumeria from '@plumeria/unplugin';
|
|
108
|
+
export default {
|
|
109
|
+
input: 'src/index.tsx',
|
|
110
|
+
plugins: [
|
|
111
|
+
plumeria.rollup(),
|
|
112
|
+
],
|
|
113
|
+
};
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Rolldown
|
|
117
|
+
```js
|
|
118
|
+
// rolldown.config.js
|
|
119
|
+
import plumeria from '@plumeria/unplugin';
|
|
120
|
+
export default {
|
|
121
|
+
input: 'src/index.tsx',
|
|
122
|
+
plugins: [
|
|
123
|
+
plumeria.rolldown(),
|
|
124
|
+
],
|
|
125
|
+
};
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Bun
|
|
129
|
+
```js
|
|
130
|
+
// build.js
|
|
131
|
+
import plumeria from '@plumeria/unplugin';
|
|
132
|
+
await Bun.build({
|
|
133
|
+
entrypoints: ['./src/index.tsx'],
|
|
134
|
+
outdir: './dist',
|
|
135
|
+
plugins: [
|
|
136
|
+
plumeria.bun(),
|
|
137
|
+
],
|
|
138
|
+
});
|
|
139
|
+
```
|
|
140
|
+
## Options
|
|
141
|
+
|
|
142
|
+
You can control the files to be converted by passing options when calling the plugin. By default, `\.(ts|tsx|js|jsx)$` is targeted.
|
|
143
|
+
|
|
144
|
+
```js
|
|
145
|
+
plumeria.vite({
|
|
146
|
+
// Files to be converted
|
|
147
|
+
include: [/\.[jt]sx?$/],
|
|
148
|
+
// Files to exclude from conversion
|
|
149
|
+
exclude: [/node_modules/],
|
|
150
|
+
|
|
151
|
+
// Whether to emit styles to disk in development mode
|
|
152
|
+
devEmitToDisk: false,
|
|
153
|
+
});
|
|
154
|
+
```
|
|
155
|
+
## Development Mode and HMR (Hot Module Replacement)
|
|
156
|
+
|
|
157
|
+
`@plumeria/unplugin` provides HMR optimized for each bundler in development mode (dev server).
|
|
158
|
+
|
|
159
|
+
- **Vite / Farm / Webpack / Rspack**: The plugin extracts styles as virtual CSS modules, enabling seamless updates via hot reloading.
|
package/dist/bun.d.ts
ADDED
package/dist/bun.js
ADDED
package/dist/bun.mjs
ADDED
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { UnpluginFactory } from 'unplugin';
|
|
2
|
+
export interface PluginOptions {
|
|
3
|
+
include?: string | RegExp | Array<string | RegExp>;
|
|
4
|
+
exclude?: string | RegExp | Array<string | RegExp>;
|
|
5
|
+
devEmitToDisk?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const TARGET_EXTENSIONS: string[];
|
|
8
|
+
export declare const EXTENSION_PATTERN: RegExp;
|
|
9
|
+
export declare const unpluginFactory: UnpluginFactory<PluginOptions | undefined>;
|