vite.config.ts 文件
import vue from '@vitejs/plugin-vue'
const path = require('path')
// vite.config.js # or vite.config.ts
module.exports = {
plugins: [vue()],
"resolve.alias": {
// 键必须以斜线开始和结束
'/@/': path.resolve(__dirname, './src')
},
build: {
outDir: 'build',
assetsDir: 'assets',
manifest: false,
rollupOptions: {
output: {
entryFileNames: `assets/[name].js`,
chunkFileNames: `assets/[name].js`,
assetFileNames: `assets/[name].[ext]`,
}
}
},
publicDir: false,
/**
* 在生产中服务时的基本公共路径。
* @default '/'
*/
base: './',
}
核心:
rollupOptions: {
output: {
entryFileNames: `assets/[name].js`,
chunkFileNames: `assets/[name].js`,
assetFileNames: `assets/[name].[ext]`,
}
}