MCPcopy Create free account
hub / github.com/esengine/esengine / pluginPreset

Function pluginPreset

packages/build-config/src/presets/plugin.ts:63–125  ·  view source on GitHub ↗
(options: PluginPackageOptions)

Source from the content-addressed store, hash-verified

61 * ```
62 */
63export function pluginPreset(options: PluginPackageOptions): UserConfig {
64 const {
65 root,
66 entries = {},
67 hasCSS = false,
68 external = [],
69 viteConfig = {}
70 } = options;
71
72 const mainEntry = entries.main ?? 'src/index.ts';
73 const runtimeEntry = entries.runtime ?? 'src/runtime.ts';
74 const editorEntry = entries.editor ?? 'src/editor/index.ts';
75
76 // 构建入口点映射
77 const entryPoints: Record<string, string> = {
78 index: resolve(root, mainEntry),
79 runtime: resolve(root, runtimeEntry),
80 'editor/index': resolve(root, editorEntry)
81 };
82
83 const plugins: any[] = [
84 dts({
85 include: ['src'],
86 outDir: 'dist',
87 rollupTypes: false
88 })
89 ];
90
91 // CSS 注入插件
92 if (hasCSS) {
93 plugins.push(cssInjectPlugin());
94 }
95
96 return defineConfig({
97 plugins,
98 esbuild: {
99 jsx: 'automatic',
100 },
101 build: {
102 lib: {
103 entry: entryPoints,
104 formats: ['es'],
105 fileName: (_format: string, entryName: string) => `${entryName}.js`
106 },
107 rollupOptions: {
108 external: [
109 ...STANDARD_EXTERNALS,
110 ...external
111 ],
112 output: {
113 exports: 'named',
114 preserveModules: false,
115 // 禁用自动代码分割,所有共享代码内联到各入口
116 manualChunks: () => undefined
117 }
118 },
119 target: 'es2020',
120 minify: false,

Callers

nothing calls this directly

Calls 3

cssInjectPluginFunction · 0.90
resolveFunction · 0.85
pushMethod · 0.65

Tested by

no test coverage detected