Instead of getting the default output js file like index.abc123.js from vite build, I want to tell it what to name the output file. But I'm not sure how to do that. Here's my current vite.config.js
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig({
plugins: [vue()],
server: {
watch: {
usePolling: true
}
},
build: {
emptyOutDir: true,
outDir: '../public',
assetsDir: './dist',
}
})
Update: It took quite a bit of fiddling around to figure out what would work for our folder structure, but I finally found out how to do what I was looking for. Here's our final vite.config.js and packages.json Hopefully it helps someone else.
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig(({ command, mode }) => ({
plugins: [vue()],
server: {
watch: {
usePolling: true
}
},
build: {
emptyOutDir: true,
outDir: '../public',
minify: mode === 'development' ? false : 'terser',
rollupOptions: {
output: {
assetFileNames: 'client/rsc/[ext]/[name][extname]',
chunkFileNames: 'client/rsc/[chunks]/[name].[hash].js',
entryFileNames: 'client/rsc/js/client.js'
}
}
}
}));
packages.json
{
"name": "webpp",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build --base=/public/",
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.2.41"
},
"devDependencies": {
"@vitejs/plugin-vue": "^3.2.0",
"vite": "^3.2.0"
}
}