feat: support pwa
This commit is contained in:
@@ -10,7 +10,8 @@ import { getApplicationConditionPlugins } from '../plugins';
|
||||
import { getCommonConfig } from './common';
|
||||
|
||||
function defineApplicationConfig(options: DefineApplicationOptions = {}) {
|
||||
return defineConfig(async ({ command, mode }) => {
|
||||
return defineConfig(async (config) => {
|
||||
const { command, mode } = config;
|
||||
const { application = {}, vite = {} } = options;
|
||||
const root = process.cwd();
|
||||
const isBuild = command === 'build';
|
||||
@@ -28,8 +29,11 @@ function defineApplicationConfig(options: DefineApplicationOptions = {}) {
|
||||
isBuild,
|
||||
mock: true,
|
||||
mode,
|
||||
pwa: true,
|
||||
turboConsole: false,
|
||||
...application,
|
||||
...(typeof application === 'function'
|
||||
? application(config)
|
||||
: application),
|
||||
});
|
||||
|
||||
const applicationConfig: UserConfig = {
|
||||
@@ -91,7 +95,10 @@ function defineApplicationConfig(options: DefineApplicationOptions = {}) {
|
||||
await getCommonConfig(),
|
||||
applicationConfig,
|
||||
);
|
||||
return mergeConfig(mergedConfig, vite);
|
||||
return mergeConfig(
|
||||
mergedConfig,
|
||||
typeof vite === 'function' ? vite(config) : vite,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -10,7 +10,8 @@ import { getLibraryConditionPlugins } from '../plugins';
|
||||
import { getCommonConfig } from './common';
|
||||
|
||||
function defineLibraryConfig(options: DefineLibraryOptions = {}) {
|
||||
return defineConfig(async ({ command, mode }) => {
|
||||
return defineConfig(async (config) => {
|
||||
const { command, mode } = config;
|
||||
const root = process.cwd();
|
||||
const { library = {}, vite = {} } = options;
|
||||
const isBuild = command === 'build';
|
||||
@@ -20,7 +21,7 @@ function defineLibraryConfig(options: DefineLibraryOptions = {}) {
|
||||
injectLibCss: true,
|
||||
isBuild,
|
||||
mode,
|
||||
...library,
|
||||
...(typeof library === 'function' ? library(config) : library),
|
||||
});
|
||||
|
||||
const { dependencies = {}, peerDependencies = {} } =
|
||||
@@ -45,7 +46,10 @@ function defineLibraryConfig(options: DefineLibraryOptions = {}) {
|
||||
};
|
||||
const commonConfig = await getCommonConfig();
|
||||
const mergedConfig = mergeConfig(commonConfig, packageConfig);
|
||||
return mergeConfig(mergedConfig, vite);
|
||||
return mergeConfig(
|
||||
mergedConfig,
|
||||
typeof vite === 'function' ? vite(config) : vite,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user