Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

268
Views
Change output structure in Vite

I am new to Vite and I have a feeling that I am missing something. I am trying to export files to their own directory, but I messed up and don't understand how to do it right.

The src folder looks like this:

my-app/
├─ node_modules/
├─ src/
│  ├─ fonts/
│  ├─ html/
│  ├─ images/
│  ├─ js/
│  ├─ static/
│  ├─ styles/
├─ package.json
├─ vite.config.js

I expect it to copy that, and so it does, but it does these "extra" things I can figure out why:

  1. There is an assets map, with some JS in it.
  2. Everything in the fonts folder is not only in the font folder, but all files are also copied to the export root.
  3. The same counts for "some" images, they are copied to the root. The strange part is that it are only a couple of images svg's only, but not all svg's.
  4. My CSS and JS files are copied to the root, not to the directories I'd like them in. I guess this is a setting. So js/app.js and css/app.css

My JS Vite.config.js

import { defineConfig } from 'vite';
export default defineConfig({
  publicDir: 'assets/',
  build: {
    emptyOutDir: true,
    outDir: '../../testproject/assets/test/',
    rollupOptions: {
      output: {
        entryFileNames: `[name].js`,
        assetFileNames: `[name].[ext]`,
      },
      input: [
        './src/js/app.js',
        './src/styles/app.scss',
      ],
    },
  },
});

Am I completely missing some settings file? I tried to reinstall in a different folder, but it does the same thing everywhere. Any idea how I can get things right?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!