一、示例
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
base: './',
build: {
assetsDir: 'static', //指定静态资源目录
rollupOptions: {
input: {
main: './index.html'
},
output: {
chunkFileNames: 'static/[name]-[hash].js', //指定 chunk 文件命名规则
entryFileNames: 'static/[name]-[hash].js', //指定入口文件命名规则
assetFileNames: 'static/[name]-[hash].[ext]' //指定资源文件(如图片)的命名规则
}
}
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src') //配置别名
}
},
server: {
fs: {
strict: false //取消对根目录限制
}
}
})