chore: Update utils4u dependency to version 2.3.0
All checks were successful
CI / cache-and-install (push) Successful in 1m26s
All checks were successful
CI / cache-and-install (push) Successful in 1m26s
This commit is contained in:
@ -3,10 +3,7 @@ import { VantResolver } from '@vant/auto-import-resolver';
|
||||
import Vue from '@vitejs/plugin-vue';
|
||||
import VueJsx from '@vitejs/plugin-vue-jsx';
|
||||
import ReactivityTransform from '@vue-macros/reactivity-transform/vite';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath, URL } from 'node:url';
|
||||
import { pinyin } from 'pinyin-pro';
|
||||
import type { OutputOptions } from 'rollup';
|
||||
import UnoCSS from 'unocss/vite';
|
||||
import AutoImport from 'unplugin-auto-import/vite';
|
||||
import { FileSystemIconLoader } from 'unplugin-icons/loaders';
|
||||
@ -18,6 +15,7 @@ import VueMacros from 'unplugin-vue-macros/vite';
|
||||
import Markdown from 'unplugin-vue-markdown/vite';
|
||||
import { getPascalCaseRouteName, VueRouterAutoImports } from 'unplugin-vue-router';
|
||||
import VueRouter from 'unplugin-vue-router/vite';
|
||||
import { createSplitChunkOutput } from 'utils4u/rollup';
|
||||
import { defineConfig, loadEnv, PluginOption } from 'vite';
|
||||
import cdnImport from 'vite-plugin-cdn-import';
|
||||
import vueDevTools from 'vite-plugin-vue-devtools';
|
||||
@ -41,53 +39,16 @@ export default defineConfig(({ mode, command }) => {
|
||||
build: {
|
||||
sourcemap: mode !== 'production' || env.VITE_SOURCE_MAP === 'true',
|
||||
rollupOptions: {
|
||||
onwarn: (warning, warn) => {
|
||||
if (warning.code === 'EVAL' && warning.message.includes('node_modules/.pnpm/eruda')) return;
|
||||
warn(warning);
|
||||
},
|
||||
output: env.VITE_SPLIT_CHUNKS === 'true' ? createSplitChunkOutput() : undefined,
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
// packages/vite/src/node/plugins/splitVendorChunk.ts
|
||||
function createSplitChunkOutput(): OutputOptions {
|
||||
return {
|
||||
chunkFileNames: 'assets/chunk/[name]_[hash].js',
|
||||
entryFileNames: 'assets/entry/[name]_[hash].js',
|
||||
assetFileNames: 'assets/[ext]/[name]_[hash].[ext]',
|
||||
manualChunks: (id /* , { getModuleIds, getModuleInfo } */) => {
|
||||
if (isInNodeModules(id) /* && !isCSSRequest(id) */) {
|
||||
let pkgName = id;
|
||||
pkgName = pkgName.split('.pnpm/')?.[1] || pkgName;
|
||||
pkgName = pkgName.split('node_modules/')?.[1] || pkgName;
|
||||
pkgName = pkgName.startsWith('@') ? pkgName.split('/')[0] + '/' + pkgName.split('/')[1] : pkgName.split('/')[0];
|
||||
|
||||
if (pkgName.startsWith('@vue/') /* || pkgName === 'vue-demi' */) pkgName = 'vue';
|
||||
/* if (pkgName.includes('vue-router')) pkgName = 'vue-router'; */
|
||||
|
||||
return `libs/${pkgName}`;
|
||||
} else if (id.includes('src/components')) {
|
||||
return formatFilename(id, 'components');
|
||||
} else if (id.includes('src/pages')) {
|
||||
return formatFilename(id, 'pages');
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
function formatFilename(id: string, prefix: string) {
|
||||
let filename = path
|
||||
.basename(id)
|
||||
.split('?')[0]
|
||||
.replace(/\.\w+$/, '');
|
||||
filename = pinyin(filename, { type: 'array' }).join('');
|
||||
return `${prefix}/${filename}`;
|
||||
}
|
||||
|
||||
function isInNodeModules(id: string): boolean {
|
||||
return id.includes('node_modules');
|
||||
}
|
||||
/* const CSS_LANGS_RE = /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
|
||||
const isCSSRequest = (request: string): boolean => CSS_LANGS_RE.test(request); */
|
||||
}
|
||||
|
||||
function Plugins() {
|
||||
const plugins: PluginOption[] = [];
|
||||
|
||||
@ -137,7 +98,6 @@ function Plugins() {
|
||||
],
|
||||
}),
|
||||
Icons({
|
||||
compiler: 'vue3',
|
||||
autoInstall: true,
|
||||
customCollections: {
|
||||
svg: FileSystemIconLoader('src/assets/icons/svgs', (svg) => {
|
||||
|
Reference in New Issue
Block a user