代码拉取完成,页面将自动刷新
import vue from '@vitejs/plugin-vue';
import {defineConfig} from 'vite';
import AutoImport from 'unplugin-auto-import/vite';
import vueSetupExtend from 'vite-plugin-vue-setup-extend';
import {resolve} from 'path';
import {loadEnv} from './src/utils/viteBuild';
const pathResolve = (dir) => {
return resolve(__dirname, '.', dir);
};
const {VITE_PORT, VITE_OPEN, VITE_PUBLIC_PATH} = loadEnv();
const alias = {
'@': pathResolve('./src/'),
'@assets': pathResolve('./src/assets/'),
};
const viteConfig = {
plugins: [
vue(),
vueSetupExtend(),
AutoImport({
imports: ['vue', 'vue-router', 'vuex'],
}),
],
root: process.cwd(),
resolve: {alias},
base: process.env.NODE_ENV === 'production' ? VITE_PUBLIC_PATH : './',
server: {
host: '0.0.0.0',
port: VITE_PORT,
open: VITE_OPEN
},
optimizeDeps: {
include: [
'axios',
'vue',
'vue-router',
'vuex',
'dayjs',
'echarts',
'bin-ui-next',
'js-cookie',
'brace',
],
exclude: [],
},
build: {
outDir: 'dist',
minify: 'esbuild',
sourcemap: false,
chunkSizeWarningLimit: 1500,
rollupOptions: {
output: {
entryFileNames: `assets/[name].${new Date().getTime()}.js`,
chunkFileNames: `assets/[name].${new Date().getTime()}.js`,
assetFileNames: `assets/[name].${new Date().getTime()}.[ext]`,
manualChunks(id) {
if (id.includes('/node_modules/')) {
// 设置需要独立打包的npm包
const expansions = ['bin-ui-next', 'brace']
const c = expansions.find(exp => id.includes(`/node_modules/${exp}`))
if (c) {
return `chunk-${c}`
} else {
return 'vendor'
}
}
},
},
},
},
css: {
postcss: {
plugins: [
{
postcssPlugin: 'internal:charset-removal',
AtRule: {
charset: (atRule) => {
if (atRule.name === 'charset') {
atRule.remove();
}
},
},
},
],
},
},
};
export default defineConfig(viteConfig);
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。