11ty / eleventy-plugin-vite

A plugin to use Vite with Eleventy
140 stars 10 forks source link

Use forward slash instead of `path.sep` #35

Closed anantakrishna closed 5 months ago

anantakrishna commented 1 year ago

Issue found in #22.

The issue is that entry.outputPath uses forward slashes even on Windows, therefore the condition always produces false with path.sep in the line:

if(!entry.outputPath.startsWith(this.outputDir + path.sep)) {

There is a confirmation for this in the Eleventy repo: https://github.com/11ty/eleventy/blob/8e88b0786b4330182020dd0a7bc602ff774869f6/src/TemplatePermalink.js#L194

    return normalize(outputDir + "/" + uri);

Thus, the path is combined using a forward slash, and not the path.sep. The normalize function from https://github.com/jonschlinkert/normalize-path is meant to “Normalize slashes in a file path to be posix/unix-like forward slashes.” Therefore, platform-specific separator cannot appear there even on Windows.

KiwiKilian commented 5 months ago

I'm closing this PR as similar changes landed through #46. Would be awesome to here, if the problem is fixed. Feel free to reach out in #22 if the problem still persists with the alpha.