I have a Vue.js app that relies on Vite. In this app, I have two static files that I need to copy to my dist
directory: favicon.ico
and manifest.json
. My vite.config.js
file looks like this:
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig(({command, mode }) => {
return {
assetsDir: 'res',
plugins: [vue()],
publicDir: 'dist',
root: 'src',
build: {
emptyOutDir: true,
outDir: '../dist'
}
}
});
My directory structure looks like this:
/
/dist
/src
/assets
favicon.ico
manifest.json
/res
/css
theme.css
App.vue
main.js
index.html
package.json
README.md
vite.config.js
When I compile my program using npm run build
, I can see a file named index.html
that gets created in the dist
directory. However, I have been unsuccessful in getting the favicon.ico
and manifest.json
file copied to the dist
directory, which is what I need. I tried adding publicDir: 'assets'
to the build
options. However, that didn't work. I also tried creating a public
directory under the src
directory in an effort to follow along with this documentation. However, that did not move the files to the directory. What am I doing wrong?