mirror of
https://github.com/alex8088/electron-vite.git
synced 2025-11-10 22:43:34 +08:00
refactor(config): move the isolateEntries options to the build option
This commit is contained in:
parent
08be346407
commit
fe7e631f47
@ -36,7 +36,7 @@ import { isObject, isFilePathESM, deepClone, asyncFlatten } from './utils'
|
|||||||
|
|
||||||
export { defineConfig as defineViteConfig } from 'vite'
|
export { defineConfig as defineViteConfig } from 'vite'
|
||||||
|
|
||||||
interface IsolatedEntriesOption {
|
interface IsolatedEntriesMixin {
|
||||||
/**
|
/**
|
||||||
* Build each entry point as an isolated bundle without code splitting.
|
* Build each entry point as an isolated bundle without code splitting.
|
||||||
*
|
*
|
||||||
@ -44,6 +44,11 @@ interface IsolatedEntriesOption {
|
|||||||
* preventing automatic code splitting across entries and ensuring each
|
* preventing automatic code splitting across entries and ensuring each
|
||||||
* output file is fully standalone.
|
* output file is fully standalone.
|
||||||
*
|
*
|
||||||
|
* **Important**: When using `isolatedEntries` in `preload` config, you
|
||||||
|
* should also disable `build.externalizeDeps` to ensure third-party dependencies
|
||||||
|
* from `node_modules` are bundled together, which is required for Electron
|
||||||
|
* sandbox support.
|
||||||
|
*
|
||||||
* @experimental
|
* @experimental
|
||||||
* @default false
|
* @default false
|
||||||
*/
|
*/
|
||||||
@ -73,9 +78,9 @@ interface BytecodeMixin {
|
|||||||
|
|
||||||
interface MainBuildOptions extends ViteBuildOptions, ExternalizeDepsMixin, BytecodeMixin {}
|
interface MainBuildOptions extends ViteBuildOptions, ExternalizeDepsMixin, BytecodeMixin {}
|
||||||
|
|
||||||
interface PreloadBuildOptions extends ViteBuildOptions, ExternalizeDepsMixin, BytecodeMixin {}
|
interface PreloadBuildOptions extends ViteBuildOptions, ExternalizeDepsMixin, BytecodeMixin, IsolatedEntriesMixin {}
|
||||||
|
|
||||||
interface RendererBuildOptions extends ViteBuildOptions {}
|
interface RendererBuildOptions extends ViteBuildOptions, IsolatedEntriesMixin {}
|
||||||
|
|
||||||
interface BaseViteConfig<T> extends Omit<ViteConfig, 'build'> {
|
interface BaseViteConfig<T> extends Omit<ViteConfig, 'build'> {
|
||||||
/**
|
/**
|
||||||
@ -86,9 +91,9 @@ interface BaseViteConfig<T> extends Omit<ViteConfig, 'build'> {
|
|||||||
|
|
||||||
export interface MainViteConfig extends BaseViteConfig<MainBuildOptions> {}
|
export interface MainViteConfig extends BaseViteConfig<MainBuildOptions> {}
|
||||||
|
|
||||||
export interface PreloadViteConfig extends BaseViteConfig<PreloadBuildOptions>, IsolatedEntriesOption {}
|
export interface PreloadViteConfig extends BaseViteConfig<PreloadBuildOptions> {}
|
||||||
|
|
||||||
export interface RendererViteConfig extends BaseViteConfig<RendererBuildOptions>, IsolatedEntriesOption {}
|
export interface RendererViteConfig extends BaseViteConfig<RendererBuildOptions> {}
|
||||||
|
|
||||||
export interface UserConfig {
|
export interface UserConfig {
|
||||||
/**
|
/**
|
||||||
@ -246,7 +251,7 @@ export async function resolveConfig(
|
|||||||
...configDrivenPlugins
|
...configDrivenPlugins
|
||||||
]
|
]
|
||||||
|
|
||||||
if (preloadViteConfig.isolatedEntries) {
|
if (preloadViteConfig.build?.isolatedEntries) {
|
||||||
builtInPreloadPlugins.push(
|
builtInPreloadPlugins.push(
|
||||||
isolateEntriesPlugin(
|
isolateEntriesPlugin(
|
||||||
mergeConfig(
|
mergeConfig(
|
||||||
@ -284,7 +289,7 @@ export async function resolveConfig(
|
|||||||
electronRendererConfigValidatorPlugin()
|
electronRendererConfigValidatorPlugin()
|
||||||
]
|
]
|
||||||
|
|
||||||
if (rendererViteConfig.isolatedEntries) {
|
if (rendererViteConfig.build?.isolatedEntries) {
|
||||||
builtInRendererPlugins.push(
|
builtInRendererPlugins.push(
|
||||||
isolateEntriesPlugin(
|
isolateEntriesPlugin(
|
||||||
mergeConfig(
|
mergeConfig(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user