mirror of
https://github.com/imdap/ruoyi-plus-vben5.git
synced 2026-04-23 00:38:34 +08:00
refactor: 兼容vite8
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
import type { CSSOptions, UserConfig } from 'vite';
|
||||
import type { CSSOptions, UserConfig } from "vite";
|
||||
|
||||
import type { DefineApplicationOptions } from '../typing';
|
||||
import type { DefineApplicationOptions } from "../typing";
|
||||
|
||||
import path, { relative } from 'node:path';
|
||||
import path, { relative } from "node:path";
|
||||
|
||||
import { findMonorepoRoot } from '@vben/node-utils';
|
||||
import { findMonorepoRoot } from "@vben/node-utils";
|
||||
|
||||
import { NodePackageImporter } from 'sass-embedded';
|
||||
import { defineConfig, loadEnv, mergeConfig } from 'vite';
|
||||
import { NodePackageImporter } from "sass-embedded";
|
||||
import { defineConfig, loadEnv, mergeConfig } from "vite";
|
||||
|
||||
import { defaultImportmapOptions, getDefaultPwaOptions } from '../options';
|
||||
import { loadApplicationPlugins } from '../plugins';
|
||||
import { loadAndConvertEnv } from '../utils/env';
|
||||
import { getCommonConfig } from './common';
|
||||
import { defaultImportmapOptions, getDefaultPwaOptions } from "../options";
|
||||
import { loadApplicationPlugins } from "../plugins";
|
||||
import { loadAndConvertEnv } from "../utils/env";
|
||||
import { getCommonConfig } from "./common";
|
||||
|
||||
function defineApplicationConfig(userConfigPromise?: DefineApplicationOptions) {
|
||||
return defineConfig(async (config) => {
|
||||
@@ -21,14 +21,14 @@ function defineApplicationConfig(userConfigPromise?: DefineApplicationOptions) {
|
||||
const { command, mode } = config;
|
||||
const { application = {}, vite = {} } = options || {};
|
||||
const root = process.cwd();
|
||||
const isBuild = command === 'build';
|
||||
const isBuild = command === "build";
|
||||
const env = loadEnv(mode, root);
|
||||
|
||||
const plugins = await loadApplicationPlugins({
|
||||
archiver: true,
|
||||
archiverPluginOptions: {},
|
||||
compress: false,
|
||||
compressTypes: ['brotli', 'gzip'],
|
||||
compressTypes: ["brotli", "gzip"],
|
||||
devtools: true,
|
||||
env,
|
||||
extraAppConfig: true,
|
||||
@@ -44,7 +44,7 @@ function defineApplicationConfig(userConfigPromise?: DefineApplicationOptions) {
|
||||
nitroMockOptions: {},
|
||||
print: !isBuild,
|
||||
printInfoMap: {
|
||||
'Vben Admin Docs': 'https://doc.vben.pro',
|
||||
"Vben Admin Docs": "https://doc.vben.pro",
|
||||
},
|
||||
pwa: true,
|
||||
pwaOptions: getDefaultPwaOptions(appTitle),
|
||||
@@ -60,12 +60,14 @@ function defineApplicationConfig(userConfigPromise?: DefineApplicationOptions) {
|
||||
build: {
|
||||
rolldownOptions: {
|
||||
output: {
|
||||
assetFileNames: '[ext]/[name]-[hash].[ext]',
|
||||
chunkFileNames: 'js/[name]-[hash].js',
|
||||
entryFileNames: 'jse/index-[name]-[hash].js',
|
||||
experimentalMinChunkSize: 20 * 1024,
|
||||
manualChunks: {
|
||||
'antdv-next': ['antdv-next'],
|
||||
assetFileNames: "[ext]/[name]-[hash].[ext]",
|
||||
chunkFileNames: "js/[name]-[hash].js",
|
||||
entryFileNames: "jse/index-[name]-[hash].js",
|
||||
// experimentalMinChunkSize: 20 * 1024,
|
||||
manualChunks(id) {
|
||||
if (id.includes("antdv-next")) {
|
||||
return "antdv-next";
|
||||
}
|
||||
},
|
||||
minify: isBuild
|
||||
? {
|
||||
@@ -76,7 +78,7 @@ function defineApplicationConfig(userConfigPromise?: DefineApplicationOptions) {
|
||||
: false,
|
||||
},
|
||||
},
|
||||
target: 'es2015',
|
||||
target: "es2015",
|
||||
},
|
||||
css: createCssOptions(injectGlobalScss),
|
||||
plugins,
|
||||
@@ -86,9 +88,9 @@ function defineApplicationConfig(userConfigPromise?: DefineApplicationOptions) {
|
||||
warmup: {
|
||||
// 预热文件
|
||||
clientFiles: [
|
||||
'./index.html',
|
||||
'./src/bootstrap.ts',
|
||||
'./src/{views,layouts,router,store,api,adapter}/*',
|
||||
"./index.html",
|
||||
"./src/bootstrap.ts",
|
||||
"./src/{views,layouts,router,store,api,adapter}/*",
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user