123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- import { URL, fileURLToPath } from 'node:url'
- import { defineConfig } from 'vite'
- import legacy from '@vitejs/plugin-legacy'
- import vue2 from '@vitejs/plugin-vue2'
- // plugins
- import AutoImport from 'unplugin-auto-import/vite'
- import Components from 'unplugin-vue-components/vite'
- import Icons from 'unplugin-icons/vite'
- import IconsResolver from 'unplugin-icons/resolver'
- import { FileSystemIconLoader } from 'unplugin-icons/loaders'
- import { ElementUiResolver } from "unplugin-vue-components/resolvers";
- import viteCompression from 'vite-plugin-compression'
- import visualizer from 'rollup-plugin-visualizer'
- export default defineConfig(({ command }) => {
- return {
- base: './',
- assetsInclude: ['assets/'],
- css: {
- preprocessorOptions: {
- less: {
- javascriptEnabled: true,
- additionalData: '@import "@/style/common.less";',
- },
- },
- },
- build: {
- outDir: 'dist',
- sourcemap: false,
- chunkSizeWarningLimit: 1000,
- rollupOptions: {
- output: {
- // 分类输出
- // chunkFileNames: 'js/[name]-[hash].js',
- // entryFileNames: 'js/[name]-[hash].js',
- // assetFileNames: '[ext]/[name]-[hash].[ext]',
- // manualChunks(id) {
- // // 打包拆分js
- // if (id.includes('node_modules')) {
- // return id.toString().split('node_modules/')[1].split('/')[0].toString()
- // }
- // },
- },
- },
- },
- resolve: {
- alias: {
- '@/': new URL('./src/', import.meta.url).pathname,
- },
- },
- plugins: [
- vue2(),
- legacy({
- targets: ['ie >= 11'],
- additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
- }),
- AutoImport({
- imports: [
- 'vue',
- 'vue-router',
- 'vuex',
- ],
- dts: false,
- resolvers: [],
- }),
- Components({
- resolvers: [
- ElementUiResolver(),
- IconsResolver({
- prefix: 'i',
- }),
- ],
- dts: false,
- }),
- Icons({
- // experimental
- 'autoInstall': true,
- 'my-icons': FileSystemIconLoader('./assets/icons', svg => svg),
- }),
- viteCompression({
- verbose: true,
- disable: false,
- deleteOriginFile: false,
- threshold: 10240,
- algorithm: 'gzip',
- ext: '.gz',
- }),
- visualizer({
- emitFile: true,
- filename: 'build/stats.html',
- open: false,
- gzipSize: true,
- brotliSize: true,
- }),
- // viteMockServe({
- // mockPath: 'mock',
- // localEnabled: command === 'serve',
- // prodEnabled: false,
- // supportTs: false,
- // watchFiles: true,
- // }),
- ],
- server: {
- host: "0.0.0.0",
- port: 8081,
- proxy: {},
- open: false,
- },
- }
- })
|