Skip to content

Commit

Permalink
updated unocss
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Dec 7, 2024
1 parent 8315fdb commit c079509
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Go to the `v1` branch to see the changelog of Lume 1.
- Added tests for middlewares.
- Types errors in Deno 2.1.
- `og_images` plugin: make satori options type partial.
- Fixed `--port` configuration [#704] on serve mode.
- Fixed `--port` configuration on serve mode [#704].
- Updates dependencies: `std`, `sass`, `liquidjs`, `tailwindcss`, `postcss`, `lightningcss`, `preact`, `decap-cms`, `unocss`, `magic-string`, `vento`, `satori`, `terser`, `markdown-it-attrs` and some icons.

## [2.4.2] - 2024-11-10
Expand Down
24 changes: 20 additions & 4 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,26 @@
]
},
"tasks": {
"test": "TZ=Z LUME_LOGS=ERROR DENO_FUTURE=1 deno test -A",
"test:update": "deno task test -- --update",
"changelog": "deno run --allow-read --allow-write https://deno.land/x/[email protected]/bin.ts",
"update-deps": "deno run -A --quiet 'https://deno.land/x/[email protected]/cli.ts' update deps/*.ts deno.json"
"test": {
"description": "Run all Lume tests. You can run only one test with `deno task test tests/<filename>`",
"command": "TZ=Z LUME_LOGS=ERROR DENO_FUTURE=1 deno test -A"
},
"test:update": {
"description": "Update all tests snapshots",
"command": "deno task test -- --update"
},
"changelog": {
"description": "Run the changelog utility to format the CHANGELOG.md file",
"command": "deno run --allow-read --allow-write https://deno.land/x/[email protected]/bin.ts"
},
"update": {
"description": "Run the nudd utility to update dependencies. I.e. `deno task update deps/dom.ts`",
"command": "deno run -A --quiet 'https://deno.land/x/[email protected]/cli.ts' update"
},
"update-deps": {
"description": "Update all dependencies to the latest version. Add `--dry-run` to don't write the changes",
"command": "deno task update deps/*.ts deno.json"
}
},
"imports": {
"lume/cms/": "https://cdn.jsdelivr.net/gh/lumeland/[email protected]/"
Expand Down
12 changes: 6 additions & 6 deletions deps/unocss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ export {
type SourceCodeTransformer,
type UnocssPluginContext,
type UserConfig,
} from "npm:@unocss/core@0.64.1";
export { presetUno } from "npm:@unocss/preset-uno@0.64.1";
export { default as transformerVariantGroup } from "npm:@unocss/transformer-variant-group@0.64.1";
export { default as transformerDirectives } from "npm:@unocss/transformer-directives@0.64.1";
export { default as MagicString } from "npm:[email protected].13";
} from "npm:@unocss/core@0.65.1";
export { presetUno } from "npm:@unocss/preset-uno@0.65.1";
export { default as transformerVariantGroup } from "npm:@unocss/transformer-variant-group@0.65.1";
export { default as transformerDirectives } from "npm:@unocss/transformer-directives@0.65.1";
export { default as MagicString } from "npm:[email protected].14";

export const resetUrl = "https://cdn.jsdelivr.net/npm/@unocss/reset@0.64.1";
export const resetUrl = "https://cdn.jsdelivr.net/npm/@unocss/reset@0.65.1";
11 changes: 10 additions & 1 deletion plugins/unocss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,19 @@ export function unoCSS(userOptions?: Options) {
const options = merge(defaults, userOptions);

return (site: Site) => {
const uno = createGenerator(options.options);
let uno: ReturnType<typeof createGenerator>;
function getGenerator() {
if (!uno) {
uno = createGenerator(options.options);
}
return uno;
}
const { transformers, cssFile, reset } = options;

if (transformers.length > 0) {
site.loadAssets([".css"]);
site.process([".css"], async (files) => {
const uno = await getGenerator();
for (const file of files) {
if (file.content) {
const code = new MagicString(file.content.toString());
Expand All @@ -105,6 +112,7 @@ export function unoCSS(userOptions?: Options) {
// Insert a <style> tag for each page
site.process([".html"], async (pages) => {
const resetCss = await getResetCss(reset);
const uno = await getGenerator();

await Promise.all(pages.map(async (page) => {
const document = page.document!;
Expand All @@ -126,6 +134,7 @@ export function unoCSS(userOptions?: Options) {
// Generate the stylesheets for all pages
site.process([".html"], async (pages) => {
const classes = new Set<string>();
const uno = await getGenerator();

await Promise.all(
pages.map(async (page) =>
Expand Down

0 comments on commit c079509

Please sign in to comment.