@visulima/rollup-plugin-css 1.0.0-alpha.2 → 1.0.0-alpha.20
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/CHANGELOG.md +191 -0
- package/LICENSE.md +83 -79
- package/README.md +164 -146
- package/dist/index.d.ts +2 -3
- package/dist/index.js +1 -0
- package/dist/loaders/less/index.d.ts +16 -9
- package/dist/loaders/less/index.js +1 -0
- package/dist/loaders/lightningcss.d.ts +2 -3
- package/dist/loaders/lightningcss.js +3 -0
- package/dist/loaders/postcss/index.d.ts +2 -3
- package/dist/loaders/postcss/index.js +6 -0
- package/dist/loaders/sass/index.d.ts +17 -9
- package/dist/loaders/sass/{index.mjs → index.js} +5 -5
- package/dist/loaders/sourcemap.d.ts +2 -3
- package/dist/loaders/sourcemap.js +1 -0
- package/dist/loaders/stylus/index.d.ts +16 -9
- package/dist/loaders/stylus/index.js +1 -0
- package/dist/loaders/tailwindcss-oxide.d.ts +2 -3
- package/dist/loaders/tailwindcss-oxide.js +1 -0
- package/dist/minifiers/cssnano.d.ts +2 -3
- package/dist/minifiers/lightningcss.d.ts +2 -3
- package/dist/packem_shared/concat-WcWAYbOc.js +3 -0
- package/dist/packem_shared/{cssModulesTypesPlugin-B9_bJo_B.mjs → cssModulesTypesPlugin-CjGroK2y.js} +1 -1
- package/dist/packem_shared/{generate-js-exports-Dqps7nWG.mjs → generate-js-exports-BhS4eLrN.js} +1 -1
- package/dist/packem_shared/getMap-TR-0DXUr.js +1 -0
- package/dist/packem_shared/inferModeOption-9h3Eq6JH.js +1 -0
- package/dist/packem_shared/loadModule-D20jQQNu.js +1 -0
- package/dist/packem_shared/resolve-anj9ucIq.js +1 -0
- package/dist/packem_shared/rollupCssPlugin-BdsDsdTA.js +3 -0
- package/dist/packem_shared/{sourcemap-DGfgaUBb.mjs → sourcemap-CB6ochh0.js} +1 -1
- package/dist/packem_shared/{types-CA9pSumu.d.mts → types-BeCJXZiE.d.ts} +1 -2
- package/dist/utils/index.d.ts +1 -2
- package/dist/utils/index.js +1 -0
- package/package.json +56 -41
- package/dist/index.d.mts +0 -20
- package/dist/index.mjs +0 -1
- package/dist/loaders/less/index.d.mts +0 -17
- package/dist/loaders/less/index.mjs +0 -1
- package/dist/loaders/lightningcss.d.mts +0 -17
- package/dist/loaders/lightningcss.mjs +0 -3
- package/dist/loaders/postcss/index.d.mts +0 -17
- package/dist/loaders/postcss/index.mjs +0 -6
- package/dist/loaders/sass/index.d.mts +0 -18
- package/dist/loaders/sourcemap.d.mts +0 -17
- package/dist/loaders/sourcemap.mjs +0 -1
- package/dist/loaders/stylus/index.d.mts +0 -17
- package/dist/loaders/stylus/index.mjs +0 -1
- package/dist/loaders/tailwindcss-oxide.d.mts +0 -17
- package/dist/loaders/tailwindcss-oxide.mjs +0 -1
- package/dist/minifiers/cssnano.d.mts +0 -17
- package/dist/minifiers/lightningcss.d.mts +0 -17
- package/dist/packem_shared/concat-BbvpVPBg.mjs +0 -3
- package/dist/packem_shared/getMap-BL5hKEnR.mjs +0 -1
- package/dist/packem_shared/inferModeOption-BWjmFhVF.mjs +0 -1
- package/dist/packem_shared/loadModule-CovDETwT.mjs +0 -1
- package/dist/packem_shared/resolve-nqhcPNJ9.mjs +0 -1
- package/dist/packem_shared/rollupCssPlugin-BTt64HIx.mjs +0 -3
- package/dist/packem_shared/types-CA9pSumu.d.ts +0 -189
- package/dist/utils/index.d.mts +0 -73
- package/dist/utils/index.mjs +0 -1
- /package/dist/minifiers/{cssnano.mjs → cssnano.js} +0 -0
- /package/dist/minifiers/{lightningcss.mjs → lightningcss.js} +0 -0
- /package/dist/packem_shared/{arrayFmt-Dek5cB7m.mjs → arrayFmt-Dek5cB7m.js} +0 -0
- /package/dist/packem_shared/{ensure-auto-modules-BU3xWEjl.mjs → ensure-auto-modules-BU3xWEjl.js} +0 -0
- /package/dist/packem_shared/{hasModuleSpecifier-DIZeev_W.mjs → hasModuleSpecifier-DIZeev_W.js} +0 -0
- /package/dist/packem_shared/{safeId-BN5akJYJ.mjs → safeId-BN5akJYJ.js} +0 -0
package/README.md
CHANGED
|
@@ -92,21 +92,21 @@ The `@visulima/rollup-plugin-css` provides comprehensive CSS processing capabili
|
|
|
92
92
|
import { rollupCssPlugin } from "@visulima/rollup-plugin-css";
|
|
93
93
|
|
|
94
94
|
export default {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
plugins: [
|
|
96
|
+
rollupCssPlugin({
|
|
97
|
+
// Extract CSS to separate files
|
|
98
|
+
mode: "extract",
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
// Enable CSS modules for .module.css files
|
|
101
|
+
autoModules: /\.module\./,
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
// Enable source maps
|
|
104
|
+
sourceMap: true,
|
|
105
105
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
106
|
+
// CSS minification
|
|
107
|
+
minifier: "cssnano",
|
|
108
|
+
}),
|
|
109
|
+
],
|
|
110
110
|
};
|
|
111
111
|
```
|
|
112
112
|
|
|
@@ -116,36 +116,33 @@ export default {
|
|
|
116
116
|
import { rollupCssPlugin } from "@visulima/rollup-plugin-css";
|
|
117
117
|
|
|
118
118
|
export default {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
minifier: "lightningcss",
|
|
147
|
-
})
|
|
148
|
-
]
|
|
119
|
+
plugins: [
|
|
120
|
+
rollupCssPlugin({
|
|
121
|
+
// File extensions to process
|
|
122
|
+
extensions: [".css", ".scss", ".sass", ".less", ".styl"],
|
|
123
|
+
|
|
124
|
+
// CSS Modules configuration
|
|
125
|
+
autoModules: true,
|
|
126
|
+
namedExports: true,
|
|
127
|
+
|
|
128
|
+
// PostCSS configuration
|
|
129
|
+
postcss: {
|
|
130
|
+
plugins: [require("autoprefixer"), require("tailwindcss")],
|
|
131
|
+
modules: {
|
|
132
|
+
generateScopedName: "[name]__[local]___[hash:base64:5]",
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
// Sass configuration
|
|
137
|
+
sass: {
|
|
138
|
+
includePaths: ["node_modules"],
|
|
139
|
+
outputStyle: "compressed",
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
// Minification
|
|
143
|
+
minifier: "lightningcss",
|
|
144
|
+
}),
|
|
145
|
+
],
|
|
149
146
|
};
|
|
150
147
|
```
|
|
151
148
|
|
|
@@ -157,23 +154,23 @@ export default {
|
|
|
157
154
|
import { rollupCssPlugin } from "@visulima/rollup-plugin-css";
|
|
158
155
|
|
|
159
156
|
export default {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
157
|
+
plugins: [
|
|
158
|
+
rollupCssPlugin({
|
|
159
|
+
// Inject CSS into JavaScript
|
|
160
|
+
mode: "inject",
|
|
161
|
+
|
|
162
|
+
// Enable CSS modules
|
|
163
|
+
autoModules: true,
|
|
164
|
+
|
|
165
|
+
// PostCSS with autoprefixer
|
|
166
|
+
postcss: {
|
|
167
|
+
plugins: [require("autoprefixer")],
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
// Minification
|
|
171
|
+
minifier: "cssnano",
|
|
172
|
+
}),
|
|
173
|
+
],
|
|
177
174
|
};
|
|
178
175
|
```
|
|
179
176
|
|
|
@@ -183,20 +180,24 @@ You can customize the CSS injection by specifying a custom package and method:
|
|
|
183
180
|
|
|
184
181
|
```typescript
|
|
185
182
|
rollupCssPlugin({
|
|
186
|
-
mode: [
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
183
|
+
mode: [
|
|
184
|
+
"inject",
|
|
185
|
+
{
|
|
186
|
+
// Use your own CSS injection library
|
|
187
|
+
package: "my-custom-injector",
|
|
188
|
+
method: "injectCSS",
|
|
189
|
+
|
|
190
|
+
// Other inject options...
|
|
191
|
+
container: "body",
|
|
192
|
+
prepend: true,
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
195
|
autoModules: true,
|
|
196
|
-
})
|
|
196
|
+
});
|
|
197
197
|
```
|
|
198
198
|
|
|
199
199
|
This allows you to:
|
|
200
|
+
|
|
200
201
|
- Use alternative CSS injection libraries
|
|
201
202
|
- Implement custom injection logic
|
|
202
203
|
- Override the default `@visulima/css-style-inject` behavior
|
|
@@ -207,29 +208,26 @@ This allows you to:
|
|
|
207
208
|
import { rollupCssPlugin } from "@visulima/rollup-plugin-css";
|
|
208
209
|
|
|
209
210
|
export default {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
minifier: "cssnano",
|
|
221
|
-
})
|
|
222
|
-
]
|
|
211
|
+
plugins: [
|
|
212
|
+
rollupCssPlugin({
|
|
213
|
+
mode: "extract",
|
|
214
|
+
autoModules: true,
|
|
215
|
+
postcss: {
|
|
216
|
+
plugins: [require("@tailwindcss/postcss"), require("autoprefixer")],
|
|
217
|
+
},
|
|
218
|
+
minifier: "cssnano",
|
|
219
|
+
}),
|
|
220
|
+
],
|
|
223
221
|
};
|
|
224
222
|
```
|
|
225
223
|
|
|
226
224
|
```javascript
|
|
227
225
|
// postcss.config.js
|
|
228
226
|
export default {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}
|
|
227
|
+
plugins: {
|
|
228
|
+
"@tailwindcss/postcss": {},
|
|
229
|
+
},
|
|
230
|
+
};
|
|
233
231
|
```
|
|
234
232
|
|
|
235
233
|
### Tailwind Oxide (Rust-based)
|
|
@@ -238,18 +236,18 @@ export default {
|
|
|
238
236
|
import { rollupCssPlugin } from "@visulima/rollup-plugin-css";
|
|
239
237
|
|
|
240
238
|
export default {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
239
|
+
plugins: [
|
|
240
|
+
rollupCssPlugin({
|
|
241
|
+
mode: "extract",
|
|
242
|
+
autoModules: true,
|
|
243
|
+
// Tailwind Oxide configuration
|
|
244
|
+
tailwind: {
|
|
245
|
+
oxide: true,
|
|
246
|
+
config: "./tailwind.config.js",
|
|
247
|
+
},
|
|
248
|
+
minifier: "cssnano",
|
|
249
|
+
}),
|
|
250
|
+
],
|
|
253
251
|
};
|
|
254
252
|
```
|
|
255
253
|
|
|
@@ -261,29 +259,32 @@ Embed CSS directly as strings in JavaScript modules. This reduces HTTP requests
|
|
|
261
259
|
import { rollupCssPlugin } from "@visulima/rollup-plugin-css";
|
|
262
260
|
|
|
263
261
|
export default {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
262
|
+
plugins: [
|
|
263
|
+
rollupCssPlugin({
|
|
264
|
+
mode: "inline",
|
|
265
|
+
autoModules: true,
|
|
266
|
+
namedExports: true,
|
|
267
|
+
minifier: "cssnano",
|
|
268
|
+
}),
|
|
269
|
+
],
|
|
272
270
|
};
|
|
273
271
|
```
|
|
274
272
|
|
|
275
273
|
**Benefits:**
|
|
274
|
+
|
|
276
275
|
- **Zero HTTP requests** - CSS is embedded directly in JavaScript
|
|
277
276
|
- **No race conditions** - CSS is available immediately when JavaScript executes
|
|
278
277
|
- **Smaller initial bundle** - No separate CSS file to load
|
|
279
278
|
- **Better caching** - CSS is cached with JavaScript bundle
|
|
280
279
|
|
|
281
280
|
**Trade-offs:**
|
|
281
|
+
|
|
282
282
|
- **Increased bundle size** - CSS content is included in JavaScript
|
|
283
283
|
- **No separate caching** - CSS can't be cached independently
|
|
284
284
|
- **Larger JavaScript** - Affects JavaScript parsing and execution time
|
|
285
285
|
|
|
286
286
|
**Use cases:**
|
|
287
|
+
|
|
287
288
|
- Critical CSS that must be available immediately
|
|
288
289
|
- Small CSS files where the overhead of a separate request isn't worth it
|
|
289
290
|
- Applications where CSS is dynamically generated or modified at runtime
|
|
@@ -351,19 +352,15 @@ declare const test: "index_test_bcd2d774";
|
|
|
351
352
|
declare const container: "index_container_bcd2d774";
|
|
352
353
|
|
|
353
354
|
interface ModulesExports {
|
|
354
|
-
|
|
355
|
-
|
|
355
|
+
test: string;
|
|
356
|
+
container: string;
|
|
356
357
|
}
|
|
357
358
|
|
|
358
359
|
declare const modules_c21c94f2: ModulesExports;
|
|
359
360
|
|
|
360
361
|
export default modules_c21c94f2;
|
|
361
362
|
|
|
362
|
-
export {
|
|
363
|
-
css,
|
|
364
|
-
test,
|
|
365
|
-
container
|
|
366
|
-
};
|
|
363
|
+
export { css, test, container };
|
|
367
364
|
```
|
|
368
365
|
|
|
369
366
|
### Multiple CSS Preprocessors
|
|
@@ -464,10 +461,11 @@ rollupCssPlugin({
|
|
|
464
461
|
mode: "extract", // Creates separate CSS files
|
|
465
462
|
autoModules: true,
|
|
466
463
|
minifier: "cssnano",
|
|
467
|
-
})
|
|
464
|
+
});
|
|
468
465
|
```
|
|
469
466
|
|
|
470
467
|
**Benefits:**
|
|
468
|
+
|
|
471
469
|
- **Separate caching** - CSS can be cached independently from JavaScript
|
|
472
470
|
- **Parallel loading** - CSS and JavaScript can load simultaneously
|
|
473
471
|
- **Better performance** - Smaller JavaScript bundles, faster parsing
|
|
@@ -475,12 +473,14 @@ rollupCssPlugin({
|
|
|
475
473
|
- **Selective loading** - Only load CSS for specific routes or components
|
|
476
474
|
|
|
477
475
|
**Trade-offs:**
|
|
476
|
+
|
|
478
477
|
- **Additional HTTP requests** - Separate CSS file must be fetched
|
|
479
478
|
- **Potential FOUC** - Flash of unstyled content if CSS loads after HTML
|
|
480
479
|
- **Build complexity** - Requires additional build step for CSS extraction
|
|
481
480
|
- **Dependency management** - Need to ensure CSS is loaded before JavaScript execution
|
|
482
481
|
|
|
483
482
|
**Use cases:**
|
|
483
|
+
|
|
484
484
|
- Large CSS files where separate caching is beneficial
|
|
485
485
|
- Applications with multiple CSS themes or variants
|
|
486
486
|
- Production builds where performance optimization is critical
|
|
@@ -496,10 +496,11 @@ rollupCssPlugin({
|
|
|
496
496
|
mode: "inject", // CSS embedded in JS
|
|
497
497
|
autoModules: true,
|
|
498
498
|
minifier: "cssnano",
|
|
499
|
-
})
|
|
499
|
+
});
|
|
500
500
|
```
|
|
501
501
|
|
|
502
502
|
**Benefits:**
|
|
503
|
+
|
|
503
504
|
- **No separate HTTP requests** - CSS is bundled with JavaScript
|
|
504
505
|
- **Guaranteed availability** - CSS is always available when JavaScript executes
|
|
505
506
|
- **Simplified deployment** - Single JavaScript bundle to manage
|
|
@@ -507,12 +508,14 @@ rollupCssPlugin({
|
|
|
507
508
|
- **Runtime control** - Full control over when and how CSS is applied
|
|
508
509
|
|
|
509
510
|
**Trade-offs:**
|
|
511
|
+
|
|
510
512
|
- **Larger JavaScript bundles** - CSS content increases JavaScript file size
|
|
511
513
|
- **Slower initial parsing** - JavaScript engine must process CSS content
|
|
512
514
|
- **No separate caching** - CSS can't be cached independently from JavaScript
|
|
513
515
|
- **Memory usage** - CSS content remains in JavaScript memory
|
|
514
516
|
|
|
515
517
|
**Use cases:**
|
|
518
|
+
|
|
516
519
|
- Single-page applications (SPAs) where CSS is always needed
|
|
517
520
|
- Applications requiring dynamic CSS injection
|
|
518
521
|
- Development builds where simplicity is preferred
|
|
@@ -525,34 +528,38 @@ You can customize the injection behavior by passing an object to the `mode` opti
|
|
|
525
528
|
|
|
526
529
|
```typescript
|
|
527
530
|
rollupCssPlugin({
|
|
528
|
-
mode: [
|
|
529
|
-
|
|
530
|
-
|
|
531
|
+
mode: [
|
|
532
|
+
"inject",
|
|
533
|
+
{
|
|
534
|
+
// Custom package to import the injector from
|
|
535
|
+
package: "my-custom-css-injector",
|
|
531
536
|
|
|
532
|
-
|
|
533
|
-
|
|
537
|
+
// Custom method name to import
|
|
538
|
+
method: "injectStyles",
|
|
534
539
|
|
|
535
|
-
|
|
536
|
-
|
|
540
|
+
// Container for style injection (default: "head")
|
|
541
|
+
container: "body",
|
|
537
542
|
|
|
538
|
-
|
|
539
|
-
|
|
543
|
+
// Insert styles at the beginning of container
|
|
544
|
+
prepend: true,
|
|
540
545
|
|
|
541
|
-
|
|
542
|
-
|
|
546
|
+
// Use single style tag
|
|
547
|
+
singleTag: true,
|
|
543
548
|
|
|
544
|
-
|
|
545
|
-
|
|
549
|
+
// Custom attributes for style tag
|
|
550
|
+
attributes: { "data-theme": "dark" },
|
|
546
551
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
552
|
+
// Make injector treeshakeable
|
|
553
|
+
treeshakeable: true,
|
|
554
|
+
},
|
|
555
|
+
],
|
|
550
556
|
autoModules: true,
|
|
551
557
|
minifier: "cssnano",
|
|
552
|
-
})
|
|
558
|
+
});
|
|
553
559
|
```
|
|
554
560
|
|
|
555
561
|
**Custom Package and Method:**
|
|
562
|
+
|
|
556
563
|
- **`package`**: Override the default `@visulima/css-style-inject` package
|
|
557
564
|
- **`method`**: Override the default `cssStyleInject` method name
|
|
558
565
|
- **Use case**: When you want to use your own CSS injection library or have custom injection logic
|
|
@@ -567,10 +574,11 @@ rollupCssPlugin({
|
|
|
567
574
|
autoModules: true,
|
|
568
575
|
namedExports: true,
|
|
569
576
|
minifier: "cssnano",
|
|
570
|
-
})
|
|
577
|
+
});
|
|
571
578
|
```
|
|
572
579
|
|
|
573
580
|
**When to use inline mode:**
|
|
581
|
+
|
|
574
582
|
- Small CSS files where HTTP request overhead isn't worth it
|
|
575
583
|
- Critical CSS that must be available immediately
|
|
576
584
|
- Applications with dynamic CSS generation
|
|
@@ -585,10 +593,11 @@ rollupCssPlugin({
|
|
|
585
593
|
mode: "emit", // CSS passed through build pipeline
|
|
586
594
|
autoModules: true,
|
|
587
595
|
minifier: "cssnano",
|
|
588
|
-
})
|
|
596
|
+
});
|
|
589
597
|
```
|
|
590
598
|
|
|
591
599
|
**Benefits:**
|
|
600
|
+
|
|
592
601
|
- **Build pipeline integration** - CSS can be processed by other Rollup plugins
|
|
593
602
|
- **Flexible output** - CSS can be transformed, bundled, or processed further
|
|
594
603
|
- **Custom handling** - Full control over how CSS is processed and output
|
|
@@ -596,12 +605,14 @@ rollupCssPlugin({
|
|
|
596
605
|
- **No assumptions** - Plugin doesn't make assumptions about CSS output
|
|
597
606
|
|
|
598
607
|
**Trade-offs:**
|
|
608
|
+
|
|
599
609
|
- **Manual handling required** - Need to configure other plugins to handle CSS
|
|
600
610
|
- **Build complexity** - Requires understanding of Rollup plugin pipeline
|
|
601
611
|
- **No automatic optimization** - CSS optimization must be handled separately
|
|
602
612
|
- **Configuration overhead** - More setup required for complete CSS handling
|
|
603
613
|
|
|
604
614
|
**Use cases:**
|
|
615
|
+
|
|
605
616
|
- Custom CSS processing pipelines
|
|
606
617
|
- Integration with other Rollup plugins
|
|
607
618
|
- Applications requiring specific CSS output formats
|
|
@@ -610,14 +621,15 @@ rollupCssPlugin({
|
|
|
610
621
|
|
|
611
622
|
## Mode Comparison
|
|
612
623
|
|
|
613
|
-
| Mode
|
|
614
|
-
|
|
615
|
-
| **Inject**
|
|
616
|
-
| **Extract** | Production, CDN
|
|
617
|
-
| **Inline**
|
|
618
|
-
| **Emit**
|
|
624
|
+
| Mode | Best For | Bundle Size | HTTP Requests | Caching | Complexity |
|
|
625
|
+
| ----------- | ------------------------- | ----------- | ------------- | -------- | ---------- |
|
|
626
|
+
| **Inject** | SPAs, dynamic injection | Larger JS | Single | Shared | Low |
|
|
627
|
+
| **Extract** | Production, CDN | Smaller JS | Multiple | Separate | Medium |
|
|
628
|
+
| **Inline** | Small files, critical CSS | Larger JS | Single | Shared | Low |
|
|
629
|
+
| **Emit** | Custom pipelines | Variable | Variable | Custom | High |
|
|
619
630
|
|
|
620
631
|
**Quick Decision Guide:**
|
|
632
|
+
|
|
621
633
|
- **Choose Inject** when you need guaranteed CSS availability and don't mind larger JS bundles
|
|
622
634
|
- **Choose Extract** when performance and caching are critical, especially for production
|
|
623
635
|
- **Choose Inline** when you have small CSS files and want to eliminate HTTP requests
|
|
@@ -628,17 +640,20 @@ rollupCssPlugin({
|
|
|
628
640
|
CSS Modules provide automatic class name scoping and TypeScript integration:
|
|
629
641
|
|
|
630
642
|
### Automatic TypeScript Declarations
|
|
643
|
+
|
|
631
644
|
- **Generated .d.ts files** for full IntelliSense support
|
|
632
645
|
- **Named exports** for individual class names
|
|
633
646
|
- **Default export** with complete module interface
|
|
634
647
|
- **Build-time type checking** prevents runtime errors
|
|
635
648
|
|
|
636
649
|
### Scoped Class Names
|
|
650
|
+
|
|
637
651
|
- **Automatic hashing** prevents style conflicts
|
|
638
652
|
- **Deterministic naming** for consistent builds
|
|
639
653
|
- **Development-friendly** class names for debugging
|
|
640
654
|
|
|
641
655
|
### Integration Benefits
|
|
656
|
+
|
|
642
657
|
- **Zero configuration** - works out of the box with `.module.css` files
|
|
643
658
|
- **Watch mode support** - declarations update automatically
|
|
644
659
|
- **Build pipeline integration** - seamless Rollup integration
|
|
@@ -646,18 +661,21 @@ CSS Modules provide automatic class name scoping and TypeScript integration:
|
|
|
646
661
|
## Key Features
|
|
647
662
|
|
|
648
663
|
### Tailwind Integration
|
|
664
|
+
|
|
649
665
|
- **Tailwind CSS v4** - Latest version with PostCSS integration
|
|
650
666
|
- **Tailwind Oxide** - Rust-based engine for ultra-fast processing
|
|
651
667
|
- **JIT compilation** - Generate only the CSS you use
|
|
652
668
|
- **Smart purging** - Automatic unused style removal
|
|
653
669
|
|
|
654
670
|
### Preprocessor Support
|
|
671
|
+
|
|
655
672
|
- **PostCSS** - Modern CSS transformations with extensive plugin ecosystem
|
|
656
673
|
- **Sass/SCSS** - Popular CSS extension language with variables and mixins
|
|
657
674
|
- **Less** - Dynamic stylesheet language with variables and functions
|
|
658
675
|
- **Stylus** - Expressive, dynamic CSS preprocessor
|
|
659
676
|
|
|
660
677
|
### Performance Optimization
|
|
678
|
+
|
|
661
679
|
- **Multiple minifiers** - Choose between cssnano and LightningCSS
|
|
662
680
|
- **Source maps** - Full debugging support in development
|
|
663
681
|
- **Code splitting** - Efficient CSS bundling strategies
|
|
@@ -670,12 +688,12 @@ Leverage the extensive PostCSS ecosystem through configuration files:
|
|
|
670
688
|
```javascript
|
|
671
689
|
// postcss.config.js
|
|
672
690
|
export default {
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
}
|
|
691
|
+
plugins: {
|
|
692
|
+
"@tailwindcss/postcss": {},
|
|
693
|
+
autoprefixer: {},
|
|
694
|
+
"postcss-nested": {},
|
|
695
|
+
},
|
|
696
|
+
};
|
|
679
697
|
```
|
|
680
698
|
|
|
681
699
|
The PostCSS loader automatically detects and uses your PostCSS configuration.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Plugin } from 'rollup';
|
|
2
|
-
import { S as StyleOptions } from './packem_shared/types-
|
|
3
|
-
export { A as AutoModules, E as ExtractedData, I as InjectOptions, a as InternalStyleOptions, L as LightningCSSOptions, P as PostCSSConfigLoaderOptions, b as PostCSSOptions } from './packem_shared/types-
|
|
2
|
+
import { S as StyleOptions } from './packem_shared/types-BeCJXZiE.js';
|
|
3
|
+
export { A as AutoModules, E as ExtractedData, I as InjectOptions, a as InternalStyleOptions, L as LightningCSSOptions, P as PostCSSConfigLoaderOptions, b as PostCSSOptions } from './packem_shared/types-BeCJXZiE.js';
|
|
4
4
|
import { Environment } from '@visulima/packem-share/types';
|
|
5
5
|
import 'cssnano';
|
|
6
6
|
import 'lightningcss';
|
|
7
7
|
import 'postcss';
|
|
8
8
|
import 'postcss-load-config';
|
|
9
|
-
import 'less';
|
|
10
9
|
import 'sass';
|
|
11
10
|
import 'sass-embedded';
|
|
12
11
|
import 'stylus';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as e}from"./packem_shared/cssModulesTypesPlugin-CjGroK2y.js";import{default as u}from"./packem_shared/rollupCssPlugin-BdsDsdTA.js";export{e as cssModulesTypesPlugin,u as rollupCssPlugin};
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { c as Loader, d as LESSLoaderOptions } from '../../packem_shared/types-BeCJXZiE.js';
|
|
2
|
+
import 'cssnano';
|
|
3
|
+
import 'lightningcss';
|
|
4
|
+
import 'postcss';
|
|
5
|
+
import 'postcss-load-config';
|
|
6
|
+
import '@visulima/packem-share/types';
|
|
7
|
+
import 'sass';
|
|
8
|
+
import 'sass-embedded';
|
|
9
|
+
import 'stylus';
|
|
10
|
+
import '@visulima/packem-share/utils';
|
|
11
|
+
import 'rollup';
|
|
12
|
+
import 'source-map-js';
|
|
13
|
+
|
|
14
|
+
declare const loader: Loader<LESSLoaderOptions>;
|
|
15
|
+
|
|
16
|
+
export { LESSLoaderOptions, loader as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c=Object.defineProperty;var l=(s,e)=>c(s,"name",{value:e,configurable:!0});import{dirname as u,normalize as d}from"@visulima/path";import f from"less";import{readFileSync as h}from"@visulima/fs";import{resolveAlias as g}from"@visulima/path/utils";import{resolve as y}from"../../packem_shared/resolve-anj9ucIq.js";import{normalizeUrl as F,getUrlOfPartial as v}from"../../packem_shared/hasModuleSpecifier-DIZeev_W.js";var b=Object.defineProperty,m=l((s,e)=>b(s,"name",{value:e,configurable:!0}),"i");const M=[".less",".css"],x=m((s,e)=>new class extends s.FileManager{supports(){return!0}async loadFile(r,a,t){const i=F(g(r,e)),o=v(i),n={baseDirs:[],caller:"Less importer",extensions:M};Array.isArray(t.paths)&&n.baseDirs.push(...t.paths),n.baseDirs.push(a);const p=y([o,i],n);return{contents:h(p),filename:p}}},"getStylesFileManager"),A=m(s=>({install(e,r){r.addFileManager(x(e,s))}}),"importer"),U={name:"less",async process({code:s,map:e}){const r=[A(this.alias)];this.options.plugins&&r.push(...this.options.plugins);const a=f.render,t=await a(s,{...this.options,filename:this.id,plugins:r,sourceMap:{outputSourceFiles:!0,sourceMapBasepath:u(this.id)}}),i=t.imports;for(const o of i)this.deps.add(d(o));return{code:t.css,map:t.map??e}},test:/\.less$/i};export{U as default};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { c as Loader, L as LightningCSSOptions } from '../packem_shared/types-
|
|
1
|
+
import { c as Loader, L as LightningCSSOptions } from '../packem_shared/types-BeCJXZiE.js';
|
|
2
2
|
import 'cssnano';
|
|
3
3
|
import 'lightningcss';
|
|
4
4
|
import 'postcss';
|
|
5
5
|
import 'postcss-load-config';
|
|
6
|
-
import 'less';
|
|
7
6
|
import '@visulima/packem-share/types';
|
|
8
7
|
import 'sass';
|
|
9
8
|
import 'sass-embedded';
|
|
@@ -14,4 +13,4 @@ import 'source-map-js';
|
|
|
14
13
|
|
|
15
14
|
declare const lightningCSSLoader: Loader<LightningCSSOptions>;
|
|
16
15
|
|
|
17
|
-
export
|
|
16
|
+
export { lightningCSSLoader as default };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{transform as r,browserslistToTargets as a}from"lightningcss";import{n as o}from"../packem_shared/ensure-auto-modules-BU3xWEjl.js";const l={name:"lightningCSS",async process({code:t,map:i}){let s=!1;typeof this.options.modules=="boolean"?s=this.options.modules:typeof this.options.modules=="object"&&(s=o(this.options.modules.include,this.id)),this.autoModules&&this.options.modules===void 0&&(s=o(this.autoModules,this.id));const e=r({...this.options,code:Buffer.from(t),cssModules:this.options.modules??s,filename:this.id,inputSourceMap:i,minify:!1,sourceMap:!this.sourceMap,targets:a(this.browserTargets)});return e.warnings.length>0&&this.logger.warn({message:`warnings when transforming css:
|
|
2
|
+
${e.warnings.map(n=>n.message).join(`
|
|
3
|
+
`)}`}),{code:e.code.toString(),map:e.map?JSON.parse(Buffer.from(e.map).toString()):void 0,moduleSideEffects:s||typeof this.inject=="object"&&this.inject.treeshakeable?!1:"no-treeshake"}},test:/\.css$/i};export{l as default};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { c as Loader, a as InternalStyleOptions } from '../../packem_shared/types-
|
|
1
|
+
import { c as Loader, a as InternalStyleOptions } from '../../packem_shared/types-BeCJXZiE.js';
|
|
2
2
|
import 'cssnano';
|
|
3
3
|
import 'lightningcss';
|
|
4
4
|
import 'postcss';
|
|
5
5
|
import 'postcss-load-config';
|
|
6
|
-
import 'less';
|
|
7
6
|
import '@visulima/packem-share/types';
|
|
8
7
|
import 'sass';
|
|
9
8
|
import 'sass-embedded';
|
|
@@ -14,4 +13,4 @@ import 'source-map-js';
|
|
|
14
13
|
|
|
15
14
|
declare const loader: Loader<NonNullable<InternalStyleOptions["postcss"]>>;
|
|
16
15
|
|
|
17
|
-
export
|
|
16
|
+
export { loader as default };
|