Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"nodemailer": "^8.0.5",
"ora": "^9.3.0",
"oxfmt": "^0.53.0",
"pathe": "^2.0.3",
"postcss": "^8.5.6",
"postcss-calc": "^10.1.1",
"postcss-merge-longhand": "^8.0.0",
Expand Down
6 changes: 3 additions & 3 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { existsSync } from 'node:fs'
import { resolve } from 'node:path'
import { resolve } from 'pathe'
import { createJiti } from 'jiti'
import { fileURLToPath } from 'node:url'
import { createDefu } from 'defu'
Expand Down Expand Up @@ -83,15 +83,15 @@ function normalizeConfig(
merged.content = merged.content.map(p => {
// Skip already-absolute or negated patterns
if (p.startsWith('/') || p.startsWith('!')) return p
return resolve(root, p).replace(/\\/g, '/')
return resolve(root, p)
})
}

// Resolve static source patterns relative to root
if (merged.static?.source) {
merged.static.source = merged.static.source.map(p => {
if (p.startsWith('/') || p.startsWith('!')) return p
return resolve(root, p).replace(/\\/g, '/')
return resolve(root, p)
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/render/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve, extname } from 'node:path'
import { resolve, extname } from 'pathe'
import { resolveConfigObject } from '../config/index.ts'
import { runTransformers } from '../transformers/index.ts'
import { createPlaintext } from '../plaintext.ts'
Expand Down
2 changes: 1 addition & 1 deletion src/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ async function serveStats(url: string, config: MaizzleConfig, renderer: Renderer
const { rawHtml } = await getRendered(absolutePath, config, renderer)
const html = stripForHtml(rawHtml)

const sizeBytes = Buffer.byteLength(html, 'utf-8')
const sizeBytes = new TextEncoder().encode(html).length

// Count images: <img> tags and CSS background images
const imgTags = (html.match(/<img\b[^>]*>/gi) || []).length
Expand Down
2 changes: 1 addition & 1 deletion src/transformers/tailwindComponent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve } from 'node:path'
import { resolve } from 'pathe'
import type { ChildNode, Element, Comment } from 'domhandler'
import { walk } from '../utils/ast/index.ts'
import { compileTailwindCss } from '../utils/compileTailwindCss.ts'
Expand Down
2 changes: 1 addition & 1 deletion src/transformers/tailwindcss.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve, dirname, relative } from 'node:path'
import { resolve, dirname, relative } from 'pathe'
import type { ChildNode, Element } from 'domhandler'
import { walk } from '../utils/ast/index.ts'
import { decodeStyleEntities } from '../utils/decodeStyleEntities.ts'
Expand Down
4 changes: 2 additions & 2 deletions src/utils/compileTailwindCss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ export function createTailwindProcessor(config: MaizzleConfig) {
export function lowerCssSyntax(css: string): string {
const result = transform({
filename: 'email.css',
code: Buffer.from(css),
code: new TextEncoder().encode(css),
minify: false,
targets: { ie: 4 << 5 },
})

return result.code.toString()
return new TextDecoder().decode(result.code)
}

export async function optimizeTailwindCss(css: string, config: MaizzleConfig): Promise<string> {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/componentSources.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve, relative } from 'node:path'
import { resolve, relative } from 'pathe'
import type { ComponentSource } from '../types/config.ts'

/**
Expand Down Expand Up @@ -72,7 +72,7 @@ export interface ComponentNameOptions {
export function componentNameFromPath(opts: ComponentNameOptions): string {
const { filePath, dirRoot, prefix, pathPrefix } = opts

const rel = relative(dirRoot, filePath).replace(/\\/g, '/')
const rel = relative(dirRoot, filePath)
const noExt = rel.replace(/\.(vue|md)$/, '')
const segments = noExt.split('/').map(pascalCase)
const fileName = segments.pop() ?? ''
Expand Down
4 changes: 2 additions & 2 deletions src/utils/watchPaths.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { matchesGlob, relative } from 'node:path'
import { matchesGlob, relative } from 'pathe'

/**
* Build a predicate that tells whether an absolute file path emitted by
Expand All @@ -9,7 +9,7 @@ import { matchesGlob, relative } from 'node:path'
export function createWatchedFileMatcher(patterns: string[], cwd: string) {
const normalized = patterns.map(p => p.replace(/^\.\//, ''))
return (file: string) => {
const rel = relative(cwd, file).replace(/\\/g, '/')
const rel = relative(cwd, file)
return normalized.some(p => matchesGlob(rel, p))
}
}
Loading