Skip to content

Commit

Permalink
fix: storybook compatibility, plugins can now add entrypoints (#488)
Browse files Browse the repository at this point in the history
* Allow rollupOptions set by other plugins to be respected

Storybook (builder-vite) adds an `iframe.html` entry into the `rollupOptions` when building a static build. I found that `vite-plugin-ruby` is overriding these options meaning that the Storybook build fails.

Here I am allowing any existing rollup options + inputs to be spread into the config before the plugin returns it.

* refactor: avoid function

---------

Co-authored-by: Maximo Mussini <maximomussini@gmail.com>
  • Loading branch information
blake-simpson and ElMassimo authored Sep 4, 2024
1 parent 36d3e96 commit a8103b7
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions vite-plugin-ruby/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ function config (userConfig: UserConfig, env: ConfigEnv): UserConfig {

const isLocal = config.mode === 'development' || config.mode === 'test'

const rollupOptions = userConfig.build?.rollupOptions
let rollupInput = rollupOptions?.input

// Normalize any entrypoints provided by plugins.
if (typeof rollupInput === 'string')
rollupInput = { [rollupInput]: rollupInput }

const build = {
emptyOutDir: userConfig.build?.emptyOutDir ?? (ssrBuild || isLocal),
sourcemap: !isLocal,
Expand All @@ -45,10 +52,14 @@ function config (userConfig: UserConfig, env: ConfigEnv): UserConfig {
manifest: !ssrBuild,
outDir,
rollupOptions: {
input: Object.fromEntries(filterEntrypointsForRollup(entrypoints)),
...rollupOptions,
input: {
...rollupInput,
...Object.fromEntries(filterEntrypointsForRollup(entrypoints)),
},
output: {
...outputOptions(assetsDir, ssrBuild),
...userConfig.build?.rollupOptions?.output,
...rollupOptions?.output,
},
},
}
Expand Down

0 comments on commit a8103b7

Please sign in to comment.