dataease-dm/core/core-frontend/config/common.ts

101 lines
2.5 KiB
Java
Raw Normal View History

2023-10-23 22:00:14 +08:00
import path from 'path'
import { resolve } from 'path'
import Vue from '@vitejs/plugin-vue'
import eslintPlugin from 'vite-plugin-eslint'
import VueJsx from '@vitejs/plugin-vue-jsx'
import viteStylelint from 'vite-plugin-stylelint'
import {
createStyleImportPlugin,
ElementPlusSecondaryResolve
} from 'vite-plugin-style-import-secondary'
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components-secondary/vite'
import { ElementPlusResolver } from 'unplugin-vue-components-secondary/resolvers'
const root = process.cwd()
export function pathResolve(dir: string) {
return resolve(root, '.', dir)
}
export default {
2023-12-26 18:44:09 +08:00
base: './',
2023-10-23 22:00:14 +08:00
plugins: [
Vue(),
VueJsx(),
createStyleImportPlugin({
resolves: [ElementPlusSecondaryResolve()],
libs: [
{
libraryName: 'element-plus-secondary',
esModule: true,
resolveStyle: name => {
return `element-plus-secondary/es/components/${name.substring(3)}/style/css`
}
}
]
}),
AutoImport({
resolvers: [ElementPlusResolver()]
}),
Components({
resolvers: [ElementPlusResolver()]
}),
createSvgIconsPlugin({
iconDirs: [pathResolve('src/assets/svg')],
symbolId: 'icon-[dir]-[name]',
customDomId: '__svg__icons__dom__de'
2023-10-23 22:00:14 +08:00
}),
VueI18nPlugin({
runtimeOnly: false,
compositionOnly: true,
include: [resolve(__dirname, 'src/locales/**')]
}),
eslintPlugin({
cache: false,
include: [
'src/**/*.ts',
'src/**/*.tsx',
'src/**/*.js',
'src/**/*.vue',
'src/*.ts',
'src/*.js',
'src/*.vue'
]
}),
viteStylelint()
],
css: {
preprocessorOptions: {
less: {
modifyVars: {
hack: `true; @import (reference) "${path.resolve('src/style/variable.less')}";`
},
javascriptEnabled: true
}
}
},
resolve: {
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.less', '.css'],
alias: [
{
find: '@',
replacement: `${pathResolve('src')}`
}
]
},
optimizeDeps: {
include: [
'vue',
'vue-router',
'vue-types',
'element-plus-secondary/es/locale/lang/zh-cn',
'element-plus-secondary/es/locale/lang/en',
'@vueuse/core',
'axios'
]
}
}