1 Star 0 Fork 72

tanml/vue3-admin-element-template

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
vite.config.js 3.52 KB
Copy Edit Raw Blame History
Admin authored 2022-06-26 20:55 . fix: 去掉主题切换功能
import { defineConfig } from 'vite';
const path = require('path');
import vue from '@vitejs/plugin-vue';
import legacy from '@vitejs/plugin-legacy';
import { viteMockServe } from 'vite-plugin-mock';
import { setting } from './src/config/setting';
import { svgBuilder } from './src/plugin/svgBuilder';
import OptimizationPersist from 'vite-plugin-optimize-persist';
import PkgConfig from 'vite-plugin-package-config';
import vueI18n from '@intlify/vite-plugin-vue-i18n';
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import Icons from 'unplugin-icons/vite';
import IconsResolver from 'unplugin-icons/resolver';
const {
base,
publicDir,
outDir,
assetsDir,
sourcemap,
cssCodeSplit,
host,
port,
strictPort,
open,
cors,
brotliSize,
logLevel,
clearScreen,
drop_console,
drop_debugger,
chunkSizeWarningLimit,
} = setting;
const isDev = process.env.NODE_ENV === 'development';
const loadI18n = isDev ? vueI18n({ include: path.resolve(__dirname, './src/locales/**') }) : '';
// https://vitejs.dev/config/
export default defineConfig({
root: process.cwd(),
base,
publicDir,
logLevel,
clearScreen,
plugins: [
vue(),
PkgConfig(),
OptimizationPersist(),
loadI18n,
legacy({
polyfills: ['es.promise.finally', 'es/map', 'es/set'],
modernPolyfills: ['es.promise.finally'],
}),
AutoImport({
// 自动导入 Vue 相关函数,如:ref, reactive, toRef 等
imports: ['vue'],
resolvers: [
ElementPlusResolver(),
// 自动导入图标组件
IconsResolver({
prefix: 'Icon',
}),
],
}),
Components({
resolvers: [
ElementPlusResolver({
importStyle: 'sass',
// directives: true,
// version: "2.1.5",
}),
// 自动注册图标组件
IconsResolver({
enabledCollections: ['ep'],
}),
],
}),
Icons({
autoInstall: true,
}),
viteMockServe({
mockPath: 'mock',
supportTs: false,
localEnabled: isDev,
prodEnabled: !isDev,
injectCode: `
import { setupProdMockServer } from './mockProdServer';
setupProdMockServer();
`,
}),
svgBuilder('./src/icons/svg/'),
],
server: {
host,
port,
cors,
strictPort,
open,
fs: {
strict: false,
},
},
resolve: {
// 设置别名
alias: {
views: path.resolve(__dirname, 'src/views'),
styles: path.resolve(__dirname, 'src/styles'),
'@': path.resolve(__dirname, 'src'),
},
},
css: {
preprocessorOptions: {
// 引入公用的样式
scss: {
additionalData: `@use "@/styles/index.scss" as *; @use "@/styles/element/index.scss" as *;`,
charset: false,
},
},
},
corePlugins: {
preflight: false,
},
build: {
target: 'es2015',
outDir,
assetsDir,
sourcemap,
cssCodeSplit,
brotliSize,
// rollupOptions: {
// output: {
// // chunkFileNames: 'static/js/[name]-[hash].js',
// // entryFileNames: 'static/js/[name]-[hash].js',
// // assetFileNames: 'static/[ext]/[name]-[hash].[ext]',
// },
// },
terserOptions: {
compress: {
keep_infinity: true,
drop_console,
drop_debugger,
},
},
chunkSizeWarningLimit,
},
optimizeDeps: {
// 检测需要预构建的依赖项
include: [],
},
});
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/tanml/vue3-admin-element-template.git
git@gitee.com:tanml/vue3-admin-element-template.git
tanml
vue3-admin-element-template
vue3-admin-element-template
master

Search