Skip to content

Commit 925cf98

Browse files
authored
fix: add support for vite-rolldown (#571)
1 parent a4a0809 commit 925cf98

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

vite-plugin-ruby/src/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,19 @@ function config (userConfig: UserConfig, env: ConfigEnv): UserConfig {
4444
if (typeof rollupInput === 'string')
4545
rollupInput = { [rollupInput]: rollupInput }
4646

47+
// Detect if we're using rolldown
48+
// @ts-ignore - Vite plugin context provides meta information
49+
const isUsingRolldown = this.meta && this.meta.rolldownVersion;
50+
const optionsKey = isUsingRolldown ? "rolldownOptions" : "rollupOptions";
51+
4752
const build = {
4853
emptyOutDir: userConfig.build?.emptyOutDir ?? (ssrBuild || isLocal),
4954
sourcemap: !isLocal,
5055
...userConfig.build,
5156
assetsDir,
5257
manifest: !ssrBuild,
5358
outDir,
54-
rollupOptions: {
59+
[optionsKey]: {
5560
...rollupOptions,
5661
input: {
5762
...rollupInput,
@@ -101,6 +106,7 @@ function configureServer (server: ViteDevServer) {
101106
function outputOptions (assetsDir: string, ssrBuild: boolean) {
102107
// Internal: Avoid nesting entrypoints unnecessarily.
103108
const outputFileName = (ext: string) => ({ name }: { name: string }) => {
109+
if (typeof name === "undefined") return "";
104110
const shortName = basename(name).split('.')[0]
105111
return posix.join(assetsDir, `${shortName}-[hash].${ext}`)
106112
}

0 commit comments

Comments
 (0)