Skip to content

Commit

Permalink
fix: 修复 path 不统一问题
Browse files Browse the repository at this point in the history
  • Loading branch information
KonghaYao committed Sep 30, 2024
1 parent c0ad54c commit a5c8dfd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.1.6",
"version": "2.1.7",
"name": "vite-plugin-font",
"description": "An automatic Web Font optimization plugin that supports many platforms such as Vite, Next, Nuxt, and more.",
"main": "./dist/unplugin.js",
Expand Down
2 changes: 2 additions & 0 deletions packages/vite/src/unplugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
SubsetBundlePluginConfig,
SubsetUtils,
} from './subset/SubsetBundlePlugin.js';
import { normalizePath } from './utils/normalizePath.js';

export interface Options extends Partial<SubsetBundlePluginConfig> {
/**
Expand Down Expand Up @@ -77,6 +78,7 @@ export const unpluginFactory: UnpluginFactory<Options | undefined> = (
return {
name: 'vite-plugin-font',
loadInclude(id) {
id = normalizePath(id)
if (exclude.some((i) => i.test(id))) return false;
return include.some((i) => i.test(id));
},
Expand Down
7 changes: 7 additions & 0 deletions packages/vite/src/utils/normalizePath.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { win32, posix } from 'path';

const normalizePathRegExp = new RegExp(`\\${win32.sep}`, 'g');

export function normalizePath(filename: string) {
return filename.replace(normalizePathRegExp, posix.sep);
}

0 comments on commit a5c8dfd

Please sign in to comment.