diff --git a/.changeset/angry-impalas-sparkle.md b/.changeset/angry-impalas-sparkle.md new file mode 100644 index 0000000..ada966c --- /dev/null +++ b/.changeset/angry-impalas-sparkle.md @@ -0,0 +1,5 @@ +--- +'vite-plugin-tailwind-purgecss': patch +--- + +fix: Normalize content glob paths for Windows diff --git a/src/index.ts b/src/index.ts index ecd1e78..c7a30e3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,6 +5,7 @@ import color from 'chalk'; import * as css from 'css-tree'; import * as estree from 'estree-walker'; import htmlExtractor from 'purgecss-from-html'; +import { normalizePath, type ResolvedConfig, type Plugin } from 'vite'; import { PurgeCSS, mergeExtractorSelectors, standardizeSafelist, defaultOptions } from 'purgecss'; import { resolveTailwindConfig, @@ -15,7 +16,6 @@ import { } from './tailwind.js'; import { log, createLogger } from './logger.js'; import type { ExtractorResultDetailed } from 'purgecss'; -import type { ResolvedConfig, Plugin } from 'vite'; import type { Node } from 'estree'; import type { PurgeOptions } from './types.js'; @@ -66,7 +66,7 @@ export function purgeCss(purgeOptions?: PurgeOptions): Plugin { // if the files haven't been cached if (files.size === 0) { - const contentGlobs = getContentPaths(tailwindConfig.content); + const contentGlobs = getContentPaths(tailwindConfig.content).map((p) => normalizePath(p)); for (const file of fg.globSync(contentGlobs, { cwd: viteConfig.root, absolute: true })) { if (file.endsWith('.html')) htmlFiles.push(file); files.add(file); diff --git a/src/logger.ts b/src/logger.ts index ea94d2d..c34a6ff 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -13,7 +13,7 @@ export function createLogger(viteConfig: ResolvedConfig) { clear: () => viteConfig.logger.clearScreen('info'), colorFile: (filepath: string) => { const fp = path.parse(filepath); - const colored = color.gray(fp.dir + path.sep) + fp.base; + const colored = color.gray(fp.dir + '/') + fp.base; return colored; }, };