Skip to content

Commit

Permalink
feat(unocss): allow custom css extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
kwaa committed Nov 27, 2023
1 parent 135ef13 commit b0e4c1c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions plugins/unocss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export interface Options {
* @defaultValue `false`
*/
cssFile?: false | string;
/** The list of extensions this plugin applies to */
cssFileExtensions: string[];
/**
* Process CSS files using UnoCSS transformers.
* @defaultValue `[transformerVariantGroup(), transformerDirectives()]`
Expand All @@ -46,6 +48,7 @@ export const defaults: Options = {
presets: [presetUno()],
},
cssFile: false,
cssFileExtensions: [".css"],
cssFileTransformers: [
transformerVariantGroup(),
transformerDirectives(),
Expand All @@ -60,8 +63,8 @@ export default function (userOptions?: Partial<Options>) {
const uno = createGenerator(options.config);

if (options.cssFileTransformers!.length > 0) {
site.loadAssets([".css"]);
site.process([".css"], async (files) => {
site.loadAssets(options.cssFileExtensions);
site.process(options.cssFileExtensions, async (files) => {
for (const file of files) {
if (file.content) {
const code = new MagicString(file.content.toString());
Expand Down

0 comments on commit b0e4c1c

Please sign in to comment.