-
-
Notifications
You must be signed in to change notification settings - Fork 543
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(plugin-vite): better logic (#3583)
* refactor(plugin-vite): better \`node_modules\` collect strategy * refactor(plugin-vite): move vite config from template to plugin * feat(plugin-vite): load built in vite config * fix(plugin-vite): return `undefined` avoid `packagerConfig.ignore` logic BUG * chore(plugin-vite): remove `process` reference * feat(plugin-vite): remove copy `dependencies` to built App * chore(plugin-vite): update config * chore(plugin-vite): test add `vite.base.config.ts` * fix(template-vite): remove vite.base.config.ts * chore(plugin-vite): cleanup code style * fix(plugin-vite): necessary forge config options * chore(plugin-vite): update test --------- Co-authored-by: Keeley Hammond <khammond@slack-corp.com>
- Loading branch information
1 parent
a29dd65
commit 83fa9cf
Showing
36 changed files
with
355 additions
and
632 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { type ConfigEnv, mergeConfig, type UserConfig } from 'vite'; | ||
|
||
import { external, getBuildConfig, getBuildDefine, pluginHotRestart } from './vite.base.config'; | ||
|
||
export function getConfig(forgeEnv: ConfigEnv<'build'>): UserConfig { | ||
const { forgeConfigSelf } = forgeEnv; | ||
const define = getBuildDefine(forgeEnv); | ||
const config: UserConfig = { | ||
build: { | ||
lib: { | ||
entry: forgeConfigSelf.entry, | ||
fileName: () => '[name].js', | ||
formats: ['cjs'], | ||
}, | ||
rollupOptions: { | ||
external, | ||
}, | ||
}, | ||
plugins: [pluginHotRestart('restart')], | ||
define, | ||
resolve: { | ||
// Load the Node.js entry. | ||
conditions: ['node'], | ||
mainFields: ['module', 'jsnext:main', 'jsnext'], | ||
}, | ||
}; | ||
|
||
return mergeConfig(getBuildConfig(forgeEnv), config); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { type ConfigEnv, mergeConfig, type UserConfig } from 'vite'; | ||
|
||
import { external, getBuildConfig, pluginHotRestart } from './vite.base.config'; | ||
|
||
export function getConfig(forgeEnv: ConfigEnv<'build'>): UserConfig { | ||
const { forgeConfigSelf } = forgeEnv; | ||
const config: UserConfig = { | ||
build: { | ||
rollupOptions: { | ||
external, | ||
// Preload scripts may contain Web assets, so use the `build.rollupOptions.input` instead `build.lib.entry`. | ||
input: forgeConfigSelf.entry, | ||
output: { | ||
format: 'cjs', | ||
// It should not be split chunks. | ||
inlineDynamicImports: true, | ||
entryFileNames: '[name].js', | ||
chunkFileNames: '[name].js', | ||
assetFileNames: '[name].[ext]', | ||
}, | ||
}, | ||
}, | ||
plugins: [pluginHotRestart('reload')], | ||
}; | ||
|
||
return mergeConfig(getBuildConfig(forgeEnv), config); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { type ConfigEnv, type UserConfig } from 'vite'; | ||
|
||
import { pluginExposeRenderer } from './vite.base.config'; | ||
|
||
// https://vitejs.dev/config | ||
export function getConfig(forgeEnv: ConfigEnv<'renderer'>) { | ||
const { root, mode, forgeConfigSelf } = forgeEnv; | ||
const name = forgeConfigSelf.name ?? ''; | ||
|
||
return { | ||
root, | ||
mode, | ||
base: './', | ||
build: { | ||
outDir: `.vite/renderer/${name}`, | ||
}, | ||
plugins: [pluginExposeRenderer(name)], | ||
resolve: { | ||
preserveSymlinks: true, | ||
}, | ||
clearScreen: false, | ||
} as UserConfig; | ||
} |
Oops, something went wrong.