1 Star 6 Fork 3

Ls.c/Bee-Primevue-Admin

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vite.config.js 4.03 KB
一键复制 编辑 原始数据 按行查看 历史
Ls.c 提交于 2024-04-01 17:26 . Initial version
import * as path from 'node:path'
import { defineConfig, loadEnv } from 'vite'
import Vue from '@vitejs/plugin-vue'
import Markdown from 'unplugin-vue-markdown/vite'
import Pages from 'vite-plugin-pages'
import Restart from 'vite-plugin-restart'
import VueDevTools from 'vite-plugin-vue-devtools'
import Components from 'unplugin-vue-components/vite'
import Layouts from 'vite-plugin-vue-layouts'
import AutoImport from 'unplugin-auto-import/vite'
import Inspect from 'vite-plugin-inspect'
import Unocss from 'unocss/vite'
import Prism from 'markdown-it-prism'
import LinkAttributes from 'markdown-it-link-attributes'
import vueI18n from '@intlify/unplugin-vue-i18n/vite'
import pkg from './package.json'
const markdownWrapperClasses = 'prose prose-sm m-auto text-left'
process.env.VITE_APP_BUILD_EPOCH = new Date().getTime()
process.env.VITE_APP_VERSION = pkg.version
/**
* @type {import('vite').UserConfig}
*/
export default defineConfig(({ command, mode }) => {
const { VITE_BASE_URL } = loadEnv(mode, process.cwd(), '')
console.log('VITE_BASE_URL', VITE_BASE_URL);
return {
base: VITE_BASE_URL,
server: {
hmr: {
port: false,
path: '/ws',
},
},
// https://github.com/antfu/vite-ssg
ssgOptions: {
script: 'async',
formatting: 'minify',
},
test: {
globals: true,
include: ['test/**/*.test.ts'],
environment: 'happy-dom',
},
optimizeDeps: {
include: [
'vue-router',
'@vueuse/core',
],
exclude: [
'vue',
'vue-demi',
],
},
plugins: [
Unocss({}),
Vue({
include: [/\.vue$/, /\.md$/],
template: {
compilerOptions: {
directiveTransforms: {
styleclass: () => ({
props: [],
needRuntime: true,
}),
ripple: () => ({
props: [],
needRuntime: true,
}),
},
},
},
}),
vueI18n({
include: path.resolve(__dirname, './src/locales/**'),
}),
Components({
dts: 'src/components.d.ts',
resolvers: [
],
}),
// https://github.com/JohnCampionJr/vite-plugin-vue-layouts
Layouts(),
// https://github.com/webfansplz/vite-plugin-vue-devtools
VueDevTools(),
// https://github.com/antfu/unplugin-auto-import
AutoImport({
imports: [
'vue',
'vue-router',
'vue-i18n',
'@vueuse/head',
],
exclude: [
'**/dist/**',
],
dts: 'src/auto-import.d.ts',
}),
Pages({
// pagesDir: ['src/pages', 'src/pages2'], VITE_BASE_URL
baseRoute: VITE_BASE_URL,
pagesDir: [
{ dir: 'src/pages', baseRoute: VITE_BASE_URL},
],
extensions: ['vue', 'md'],
syncIndex: true,
replaceSquareBrackets: true,
extendRoute(route) {
if (route.name === 'about')
route.props = route => ({ query: route.query.q })
if (route.name === 'components') {
return {
...route,
beforeEnter: (route) => {
// console.log(route)
},
}
}
},
}),
Markdown({
wrapperClasses: markdownWrapperClasses,
headEnabled: true,
markdownItSetup(md) {
// https://prismjs.com/
md.use(Prism)
md.use(LinkAttributes, {
matcher: link => /^https?:\/\//.test(link),
attrs: {
target: '_blank',
rel: 'noopener',
},
})
},
}),
Restart({
restart: ['../../dist/*.js'],
}),
// https://github.com/antfu/vite-plugin-inspect
Inspect({
// change this to enable inspect for debugging
enabled: false,
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
'~': path.resolve(__dirname, 'node_modules/'),
},
},
}
})
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/lesonchan/bee-primevue-admin.git
git@gitee.com:lesonchan/bee-primevue-admin.git
lesonchan
bee-primevue-admin
Bee-Primevue-Admin
master

搜索帮助