Skip to content

Commit d09f80a

Browse files
committed
Remove default SSR entry point
With no default primary entry point, it seems weird to have a default SSR entry point. This also brings equity to Vue and React set ups where React had to override the defaults with a .jsx extension.
1 parent c8c19c3 commit d09f80a

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ interface PluginConfig {
2626

2727
/**
2828
* The path of the SSR entry point.
29-
*
30-
* @default 'resources/js/ssr.js'
3129
*/
32-
ssr?: string|string[]|undefined
30+
ssr?: string|string[]
3331

3432
/**
3533
* The directory where the SSR bundle should be written.
@@ -232,7 +230,7 @@ function resolvePluginConfig(config: string|string[]|PluginConfig): Required<Plu
232230
input: config.input,
233231
publicDirectory: config.publicDirectory ?? 'public',
234232
buildDirectory: config.buildDirectory ?? 'build',
235-
ssr: config.ssr ?? 'resources/js/ssr.js',
233+
ssr: config.ssr ?? config.input,
236234
ssrOutputDirectory: config.ssrOutputDirectory ?? 'storage/ssr',
237235
}
238236
}
@@ -249,7 +247,7 @@ function resolveBase(config: Required<PluginConfig>, assetUrl: string): string {
249247
*/
250248
function resolveInput(config: Required<PluginConfig>, ssr: boolean): string|string[]|undefined {
251249
if (ssr) {
252-
return config.ssr ?? config.input
250+
return config.ssr
253251
}
254252

255253
return config.input

tests/index.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ describe('laravel-vite-plugin', () => {
8383
expect(ssrConfig.build.rollupOptions.input).toBe('resources/js/ssr.js')
8484
})
8585

86+
it('uses the default entry point when ssr entry point is not provided', () => {
87+
// This is support users who may want a dedicated Vite config for SSR.
88+
const plugin = laravel('resources/js/ssr.js')
89+
90+
const ssrConfig = plugin.config({ build: { ssr: true } }, { command: 'build', mode: 'production' })
91+
expect(ssrConfig.build.rollupOptions.input).toBe('resources/js/ssr.js')
92+
})
93+
8694
it('prefixes the base with ASSET_URL in production mode', () => {
8795
process.env.ASSET_URL = 'http://example.com'
8896
const plugin = laravel('resources/js/app.js')

0 commit comments

Comments
 (0)