Skip to content

Commit 4e8ca1c

Browse files
committed
simplify
1 parent c1083e2 commit 4e8ca1c

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

src/build/vite/plugin.ts

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -97,31 +97,33 @@ function nitroEnv(ctx: NitroPluginContext): VitePlugin {
9797
nitro: createNitroEnvironment(ctx),
9898
};
9999

100-
let clientEntryConfigured = false;
101-
let clientEntry: string | undefined = getEntry(
100+
let clientEntry: string | undefined;
101+
let clientEntryConfigured = !!getEntry(
102102
userConfig.environments?.client?.build?.rolldownOptions?.input ||
103103
userConfig.environments?.client?.build?.rollupOptions?.input
104104
);
105-
106-
if (clientEntry) {
107-
clientEntryConfigured = true;
108-
} else {
109-
clientEntry = useNitro(ctx).options.renderer?.template;
110-
}
111-
112-
if (!clientEntry) {
113-
// Auto-detect client entry
114-
clientEntry = resolveModulePath("./entry-client", {
115-
try: true,
116-
extensions: DEFAULT_EXTENSIONS,
117-
from: ["app", "src", ""].flatMap((d) =>
118-
[ctx.nitro!.options.rootDir, ...ctx.nitro!.options.scanDirs].map(
119-
(s) => join(s, d) + "/"
120-
)
121-
),
122-
});
123-
if (clientEntry) {
124-
ctx.nitro!.logger.info(`Using \`${prettyPath(clientEntry)}\` as vite client entry.`);
105+
if (!clientEntryConfigured) {
106+
const rendererTemplate = useNitro(ctx).options.renderer?.template;
107+
if (rendererTemplate) {
108+
// Use Nitro renderer template as client entry
109+
clientEntry = rendererTemplate;
110+
ctx.nitro!.logger.info(
111+
`Using Nitro renderer template \`${prettyPath(rendererTemplate)}\` as vite client entry.`
112+
);
113+
} else {
114+
// Auto-detect client entry
115+
clientEntry = resolveModulePath("./entry-client", {
116+
try: true,
117+
extensions: DEFAULT_EXTENSIONS,
118+
from: ["app", "src", ""].flatMap((d) =>
119+
[ctx.nitro!.options.rootDir, ...ctx.nitro!.options.scanDirs].map(
120+
(s) => join(s, d) + "/"
121+
)
122+
),
123+
});
124+
if (clientEntry) {
125+
ctx.nitro!.logger.info(`Using \`${prettyPath(clientEntry)}\` as vite client entry.`);
126+
}
125127
}
126128
}
127129
if (clientEntry) {

0 commit comments

Comments
 (0)