javascriptfrontendvite

I don't want to have a src folder in my dist foler


I'm using vite in a project and my folder structure is like this

youtube_comments/
   src/
    js/
     script.js
    sass/
     styles.sass
   index.html

When i move the index.html file in the root to the src folder and convert

 rollupOptions: {
      input: {
        main: path.resolve(__dirname, 'index.html'),
      },
    },

to

 rollupOptions: {
      input: {
        main: path.resolve(__dirname, 'src/index.html'),
      },

there appears to be a src folder in my dist folder although i want my index.html to be in the root of the dist foler


Solution

  • First, You can use the outputDir property along with Rollup’s plugin or use the build option to control how paths are handled: Second, Ensure that the file paths are updated correctly when moving files from the src folder to dist. You might need to manually manage certain files if the output structure still keeps the folder nesting.