Skip to content

Commit

Permalink
fix: Use root path when building full destination (#32)
Browse files Browse the repository at this point in the history
Previously this plugin would not do anything when you put your project's site files under a folder. See the `root` [shared option]. With
this change, the user now can have source files in a folder that is not at the project root.

This may also fix #30, since I am also using Vite 5.x.

[shared option]: https://vitejs.dev/config/shared-options.html

Co-authored-by: Fateh AK <[email protected]>
  • Loading branch information
fidian and FatehAK authored May 26, 2024
1 parent 0472cff commit 782026d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ function ViteImageOptimizer(optionsParam: Options = {}): Plugin {
const handles = files.map(async (publicFilePath: string) => {
// convert the path to the output folder
const filePath: string = publicFilePath.replace(publicDir + sep, '');
const fullFilePath: string = join(outputPath, filePath);
const fullFilePath: string = join(rootConfig.root, outputPath, filePath);

if (fs.existsSync(fullFilePath) === false) return;

Expand Down

0 comments on commit 782026d

Please sign in to comment.