MeterSphere/frontend/config/vite.config.base.ts

96 lines
2.6 KiB
TypeScript
Raw Normal View History

2023-05-24 11:08:08 +08:00
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import { resolve } from 'path';
import AutoImport from 'unplugin-auto-import/vite';
import { defineConfig } from 'vite';
2023-08-07 18:07:57 +08:00
// import configArcoStyleImportPlugin from './plugin/arcoStyleImport';
// import configArcoResolverPlugin from './plugin/arcoResolver';
2023-05-24 11:08:08 +08:00
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
import vueSetupExtend from 'vite-plugin-vue-setup-extend';
import svgLoader from 'vite-svg-loader';
2023-05-24 11:08:08 +08:00
export default defineConfig({
plugins: [
vue(),
vueJsx(),
vueSetupExtend(),
2023-05-24 11:08:08 +08:00
svgLoader({ svgoConfig: {} }),
2023-08-07 18:07:57 +08:00
// configArcoResolverPlugin(),
// configArcoStyleImportPlugin(),
2023-05-24 11:08:08 +08:00
createSvgIconsPlugin({
// 指定需要缓存的图标文件夹
iconDirs: [resolve(process.cwd(), 'src/assets/svg'), resolve(process.cwd(), 'public/images')], // 与本地储存地址一致
2023-05-24 11:08:08 +08:00
// 指定symbolId格式
symbolId: 'icon-[name]',
}),
AutoImport({
include: [
/\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
/\.vue$/,
/\.vue\?vue/, // .vue
/\.md$/, // .md
],
imports: ['vue'],
dts: 'src/auto-import.d.ts',
eslintrc: {
enabled: true, // <-- this
},
}),
2023-05-24 11:08:08 +08:00
],
resolve: {
alias: [
{
find: '@',
replacement: resolve(__dirname, '../src'),
},
{
find: 'assets',
replacement: resolve(__dirname, '../src/assets'),
},
{
find: 'vue-i18n',
2023-09-11 19:26:10 +08:00
replacement: 'vue-i18n/dist/vue-i18n.esm-bundler.js', // 解决 vue-i18n 依赖包报错
2023-05-24 11:08:08 +08:00
},
{
find: 'vue',
replacement: 'vue/dist/vue.esm-bundler.js', // compile template
},
{
find: '@tiptap/pm/state',
replacement: '@halo-dev/richtext-editor',
},
{
find: '@tiptap/pm/model',
replacement: '@halo-dev/richtext-editor',
},
{
find: '@tiptap/core',
replacement: '@halo-dev/richtext-editor',
},
{
find: '@tiptap/pm/view',
replacement: '@halo-dev/richtext-editor',
},
2023-05-24 11:08:08 +08:00
],
extensions: ['.ts', '.js'],
},
define: {
'process.env': {},
// 定义特性标志
'__VUE_OPTIONS_API__': true,
'__VUE_PROD_DEVTOOLS__': false,
// 设置hydration不匹配详细信息的标志
'__VUE_PROD_HYDRATION_MISMATCH_DETAILS__': true,
2023-05-24 11:08:08 +08:00
},
css: {
preprocessorOptions: {
less: {
modifyVars: {
hack: `true; @import (reference) "${resolve('src/assets/style/var.less')}";`,
2023-05-24 11:08:08 +08:00
},
javascriptEnabled: true,
},
},
},
});