diff --git a/packages/vite/src/core.ts b/packages/vite/src/core.ts index f887849bc..3529c21eb 100644 --- a/packages/vite/src/core.ts +++ b/packages/vite/src/core.ts @@ -37,7 +37,12 @@ export default function masterCSS(options?: PluginOptions): Plugin[] { enforce: 'pre', configResolved(config) { context.config = config - context.entryId = fg.sync(ENTRY_MODULE_PATTERNS, { cwd: config.root, absolute: true, onlyFiles: true, caseSensitiveMatch: false })[0] + context.entryId = options.entryId ?? fg.sync(ENTRY_MODULE_PATTERNS, { + cwd: config.root, + absolute: true, + onlyFiles: true, + caseSensitiveMatch: false + )[0] if (process.env.DEBUG) { console.log(`[@master/css.vite] mode: ${options.mode}`) console.log(`[@master/css.vite] entry: ${context.entryId || 'none'}`) diff --git a/packages/vite/src/options.ts b/packages/vite/src/options.ts index 665e13012..794064119 100644 --- a/packages/vite/src/options.ts +++ b/packages/vite/src/options.ts @@ -60,4 +60,9 @@ export interface PluginOptions { * Useful in Runtime */ avoidFOUC?: boolean + + /** + * Specifies which entry to use when multiple entries (i.e. main.tsx and index.ts) are present. + */ + entryId?: string }