gohttpdUi/vite.config.ts

84 lines
2.1 KiB
TypeScript
Raw Normal View History

2021-10-10 09:59:52 +08:00
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
2021-10-16 09:40:39 +08:00
import { resolve } from 'path'
2021-10-10 09:59:52 +08:00
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
2021-10-16 09:40:39 +08:00
import vueJsx from '@vitejs/plugin-vue-jsx'
import vueSetupExtend from 'vite-plugin-vue-setup-extend'
import eslintPlugin from 'vite-plugin-eslint'
2021-10-23 16:35:18 +08:00
// import styleImport from 'vite-plugin-style-import'
import ElementPlus from 'unplugin-element-plus/vite'
2021-10-16 09:40:39 +08:00
import viteSvgIcons from 'vite-plugin-svg-icons'
import commonjsExternals from 'vite-plugin-commonjs-externals'
function pathResolve(dir: string) {
return resolve(process.cwd(), '.', dir)
}
2021-10-10 09:59:52 +08:00
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
2021-10-16 09:40:39 +08:00
vueJsx(),
vueSetupExtend(),
2021-10-23 16:35:18 +08:00
// styleImport({
// libs: [{
// libraryName: 'element-plus',
// resolveStyle: (name) => {
// return `element-plus/es/components/${name.split('el-')[1]}/style/css`
// }
// }]
// }),
ElementPlus({
useSource: false
2021-10-16 09:40:39 +08:00
}),
2021-10-10 09:59:52 +08:00
Components({
dts: true,
resolvers: [ElementPlusResolver()]
2021-10-16 09:40:39 +08:00
}),
eslintPlugin({
cache: false,
include: ['src/**/*.vue', 'src/**/*.ts', 'src/**/*.tsx'] // 检查的文件
}),
viteSvgIcons({
// 指定需要缓存的图标文件夹
iconDirs: [resolve(process.cwd(), 'src/assets/icons')],
// 指定symbolId格式
symbolId: 'icon-[dir]-[name]',
// 压缩
svgoOptions: true
}),
commonjsExternals({
externals: ['path']
2021-10-10 09:59:52 +08:00
})
2021-10-16 09:40:39 +08:00
],
css: {
preprocessorOptions: {
less: {
additionalData: '@import "./src/styles/variables.less";',
javascriptEnabled: true
}
}
},
resolve: {
alias: [
{
find: /\@\//,
replacement: pathResolve('src') + '/'
},
{
find: /\_v\//,
replacement: pathResolve('src/views') + '/'
},
{
find: /\_c\//,
replacement: pathResolve('src/components') + '/'
}
]
2021-10-23 16:35:18 +08:00
},
build: {
sourcemap: true
2021-10-16 09:40:39 +08:00
}
2021-10-10 09:59:52 +08:00
})