JohnPremKumar / vite-plugin-favicons-inject

A Vite plugin for creating and injecting favicons during the application build!
MIT License
11 stars 3 forks source link

Error: ENOENT: no such file or directory #4

Closed lucasfernandodev closed 2 years ago

lucasfernandodev commented 2 years ago

So I'm getting the error below during the build of the project, the path is duplicated.

In my project using a root and outDir, custom.

const root = resolve(__dirname, 'src');
const outDir = resolve(__dirname, 'dist');

Error:

error during build:
Error: ENOENT: no such file or directory, open '/home/lu/dev/entardecer/src/home/lu/dev/entardecer/dist/assets/manifest.webmanifest'
JohnPremKumar commented 2 years ago

The issue must be due to the absolute path provided for outDir, since as per the docs(https://vitejs.dev/config/build-options.html#build-outdir) outDir should be a relative path corresponding to the project root. I presume changing the outDir to the relative path should fix this issue

Also, It would be great if you share your Vite config file so I can able to reproduce this issue.

lucasfernandodev commented 2 years ago

Thanks, it worked.

vite.config.ts

import {resolve} from 'path';
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { crx } from "@crxjs/vite-plugin";
import manifest from './manifest.config';
import vitePluginFaviconInject from 'vite-plugin-favicons-inject'

const root = resolve(__dirname, 'src');
const outDir ='../dist';

// https://vitejs.dev/config/
export default defineConfig({
  root,
  plugins: [react(), crx({ manifest }), vitePluginFaviconInject('./src/public/images/logo.svg')],
  build: {
    outDir,
    emptyOutDir: true,
    rollupOptions: {
      input: {
        main: resolve(root, 'pages', 'popup', 'index.html'),
        homepage: resolve(root, 'pages', 'homepage', 'index.html')
      }
    }
  }
})