Skip to content

Commit

Permalink
fix: Normalize content glob paths (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianGonz97 authored Apr 15, 2024
1 parent db3d9d3 commit baeec98
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/angry-impalas-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'vite-plugin-tailwind-purgecss': patch
---

fix: Normalize content glob paths for Windows
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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';

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
};
Expand Down

0 comments on commit baeec98

Please sign in to comment.