代码拉取完成,页面将自动刷新
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { fileURLToPath } from 'node:url'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { defineConfig, loadEnv } from 'vite'
import Pages from 'vite-plugin-pages'
import Layouts from 'vite-plugin-vue-layouts'
import vuetify from 'vite-plugin-vuetify'
// @ts-expect-error Known error: https://github.com/sxzz/unplugin-vue-macros/issues/257#issuecomment-1410752890
import DefineOptions from 'unplugin-vue-define-options/vite'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd())
return {
plugins: [
vue(),
vueJsx(),
// https://github.com/vuetifyjs/vuetify-loader/tree/next/packages/vite-plugin
vuetify({
styles: {
configFile: 'src/styles/variables/_vuetify.scss',
},
}),
Pages({
dirs: ['./src/pages'],
// ℹ️ We need three routes using single routes so we will ignore generating route for this SFC file
onRoutesGenerated: routes => [
// Email filter
{
path: '/apps/email/:filter',
name: 'apps-email-filter',
component: '/src/pages/apps/email/index.vue',
meta: {
navActiveLink: 'apps-email',
layoutWrapperClasses: 'layout-content-height-fixed',
},
},
// Email label
{
path: '/apps/email/label/:label',
name: 'apps-email-label',
component: '/src/pages/apps/email/index.vue',
meta: {
// contentClass: 'email-application',
navActiveLink: 'apps-email',
layoutWrapperClasses: 'layout-content-height-fixed',
},
},
...routes,
],
}),
Layouts({
layoutsDirs: './src/layouts/',
}),
Components({
dirs: ['src/@core/components', 'src/views/demos', 'src/components'],
dts: true,
}),
AutoImport({
eslintrc: {
enabled: true,
filepath: './.eslintrc-auto-import.json',
},
imports: ['vue', 'vue-router', '@vueuse/core', '@vueuse/math', 'vue-i18n', 'pinia'],
vueTemplate: true,
}),
VueI18nPlugin({
runtimeOnly: true,
compositionOnly: true,
include: [
fileURLToPath(new URL('./src/plugins/i18n/locales/**',
import.meta.url)),
],
}),
DefineOptions(),
],
define: { 'process.env': {} },
resolve: {
alias: {
'@': fileURLToPath(new URL('./src',
import.meta.url)),
'@themeConfig': fileURLToPath(new URL('./themeConfig.js',
import.meta.url)),
'@core': fileURLToPath(new URL('./src/@core',
import.meta.url)),
'@layouts': fileURLToPath(new URL('./src/@layouts',
import.meta.url)),
'@images': fileURLToPath(new URL('./src/assets/images/',
import.meta.url)),
'@styles': fileURLToPath(new URL('./src/styles/',
import.meta.url)),
'@configured-variables': fileURLToPath(new URL('./src/styles/variables/_template.scss',
import.meta.url)),
'@axios': fileURLToPath(new URL('./src/plugins/axios',
import.meta.url)),
'@validators': fileURLToPath(new URL('./src/@core/utils/validators',
import.meta.url)),
'apexcharts': fileURLToPath(new URL('node_modules/apexcharts-clevision',
import.meta.url)),
},
},
server: {
// 允许IP访问
host: '0.0.0.0',
// port: Number(env.VITE_APP_PORT),
port: 4175,
// 运行是否自动打开浏览器
open: true,
},
// 构建配置
build: {
chunkSizeWarningLimit: 2000, // 消除打包大小超过500kb警告
minify: 'terser', // Vite 2.6.x 以上需要配置 minify: "terser", terserOptions 才能生效
terserOptions: {
compress: {
keep_infinity: true, // 防止 Infinity 被压缩成 1/0,这可能会导致 Chrome 上的性能问题
drop_console: true, // 生产环境去除 console
drop_debugger: true, // 生产环境去除 debugger
},
format: {
comments: false, // 删除注释
},
},
rollupOptions: {
output: {
// manualChunks: {
// "vue-i18n": ["vue-i18n"],
// },
// 用于从入口点创建的块的打包输出格式[name]表示文件名,[hash]表示该文件内容hash值
entryFileNames: 'js/[name].[hash].js',
// 用于命名代码拆分时创建的共享块的输出命名
chunkFileNames: 'js/[name].[hash].js',
// 用于输出静态资源的命名,[ext]表示文件扩展名
assetFileNames: assetInfo => {
const info = assetInfo.name.split('.')
let extType = info[info.length - 1]
// console.log('文件信息', assetInfo.name)
if (/\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/i.test(assetInfo.name)) {
extType = 'media'
} else if (/\.(png|jpe?g|gif|svg)(\?.*)?$/.test(assetInfo.name)) {
extType = 'img'
} else if (/\.(woff2?|eot|ttf|otf)(\?.*)?$/i.test(assetInfo.name)) {
extType = 'fonts'
}
return `${extType}/[name].[hash].[ext]`
},
},
},
},
optimizeDeps: {
exclude: ['vuetify'],
entries: [
'./src/**/*.vue',
],
},
}
})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。