1 Star 0 Fork 0

Beaky/xoa-vue

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vite.config.js 5.59 KB
一键复制 编辑 原始数据 按行查看 历史
Beaky 提交于 2024-04-18 09:43 . xoa
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',
],
},
}
})
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Kobe_mrcy/xoa-vue.git
[email protected]:Kobe_mrcy/xoa-vue.git
Kobe_mrcy
xoa-vue
xoa-vue
master

搜索帮助