mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-25 16:16:20 +08:00
This commit is contained in:
@@ -8,11 +8,14 @@ import { findMonorepoRoot } from '@vben/node-utils';
|
||||
|
||||
import { defineConfig, loadEnv, mergeConfig } from 'vite';
|
||||
|
||||
import { getDefaultPwaOptions } from '../options';
|
||||
import { loadApplicationPlugins } from '../plugins';
|
||||
import { loadAndConvertEnv } from '../utils/env';
|
||||
import { getCommonConfig } from './common';
|
||||
|
||||
function defineApplicationConfig(userConfigPromise: DefineApplicationOptions) {
|
||||
return defineConfig(async (config) => {
|
||||
const { appTitle, base, port, ...envConfig } = await loadAndConvertEnv();
|
||||
const options = await userConfigPromise?.(config);
|
||||
const { command, mode } = config;
|
||||
const { application = {}, vite = {} } = options || {};
|
||||
@@ -40,12 +43,15 @@ function defineApplicationConfig(userConfigPromise: DefineApplicationOptions) {
|
||||
'Vben Admin Docs': 'https://docs.vben.pro',
|
||||
},
|
||||
pwa: true,
|
||||
pwaOptions: getDefaultPwaOptions(appTitle),
|
||||
...envConfig,
|
||||
...application,
|
||||
});
|
||||
|
||||
const { injectGlobalScss = true } = application;
|
||||
|
||||
const applicationConfig: UserConfig = {
|
||||
base,
|
||||
build: {
|
||||
rollupOptions: {
|
||||
output: {
|
||||
@@ -69,6 +75,7 @@ function defineApplicationConfig(userConfigPromise: DefineApplicationOptions) {
|
||||
plugins,
|
||||
server: {
|
||||
host: true,
|
||||
port,
|
||||
warmup: {
|
||||
// 预热文件
|
||||
clientFiles: ['./index.html', './src/{views,layouts}/*'],
|
||||
|
@@ -28,7 +28,7 @@ const getDefaultPwaOptions = (name: string): Partial<PwaPluginOptions> => ({
|
||||
const defaultImportmapOptions: ImportmapPluginOptions = {
|
||||
// 通过 Importmap CDN 方式引入,
|
||||
// 目前只有esm.sh源兼容性好一点,jspm.io对于 esm 入口要求高
|
||||
defaultProvider: 'esm.sh',
|
||||
defaultProvider: 'jspm.io',
|
||||
importmap: [
|
||||
{ name: 'vue' },
|
||||
{ name: 'pinia' },
|
||||
|
@@ -110,5 +110,5 @@
|
||||
</style>
|
||||
<div class="loading" id="__app-loading__">
|
||||
<span class="dot dot-spin"><i></i><i></i><i></i><i></i></span>
|
||||
<div class="title"><%= VITE_GLOB_APP_TITLE %></div>
|
||||
<div class="title"><%= VITE_APP_TITLE %></div>
|
||||
</div>
|
||||
|
@@ -109,5 +109,5 @@
|
||||
</style>
|
||||
<div class="loading" id="__app-loading__">
|
||||
<div class="loader"></div>
|
||||
<div class="title"><%= VITE_GLOB_APP_TITLE %></div>
|
||||
<div class="title"><%= VITE_APP_TITLE %></div>
|
||||
</div>
|
||||
|
@@ -64,10 +64,10 @@ async function loadAndConvertEnv(
|
||||
> {
|
||||
const envConfig = await loadEnv(match, confFiles);
|
||||
const {
|
||||
VITE_APP_TITLE,
|
||||
VITE_BASE,
|
||||
VITE_COMPRESS,
|
||||
VITE_DEVTOOLS,
|
||||
VITE_GLOB_APP_TITLE,
|
||||
VITE_INJECT_APP_LOADING,
|
||||
VITE_NITRO_MOCK,
|
||||
VITE_PORT,
|
||||
@@ -80,7 +80,7 @@ async function loadAndConvertEnv(
|
||||
.filter((item) => item === 'brotli' || item === 'gzip');
|
||||
|
||||
return {
|
||||
appTitle: VITE_GLOB_APP_TITLE ?? 'Vben Admin',
|
||||
appTitle: VITE_APP_TITLE ?? 'Vben Admin',
|
||||
base: VITE_BASE || '/',
|
||||
compress: !!compress,
|
||||
compressTypes: compressTypes as ('brotli' | 'gzip')[],
|
||||
|
Reference in New Issue
Block a user