From 782026d558caa29b07ce4afa6e0f2d82f437d4ee Mon Sep 17 00:00:00 2001 From: Tyler Akins Date: Sun, 26 May 2024 11:39:02 -0500 Subject: [PATCH] fix: Use root path when building full destination (#32) 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 FatehAK/vite-plugin-image-optimizer#30, since I am also using Vite 5.x. [shared option]: https://vitejs.dev/config/shared-options.html Co-authored-by: Fateh AK --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index e142fd4..68829f9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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;