Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build multiple UMD files from multiple entries #7484

Closed
4 tasks done
ruofee opened this issue Mar 27, 2022 · 2 comments
Closed
4 tasks done

Build multiple UMD files from multiple entries #7484

ruofee opened this issue Mar 27, 2022 · 2 comments

Comments

@ruofee
Copy link

ruofee commented Mar 27, 2022

Clear and concise description of the problem

I cannot build multiple umd files from multiple entries.

For example:

// vite.config.ts
import { defineConfig } from 'vite'
const { resolve } = require('path')

export default defineConfig({
  build: {
    rollupOptions: {
      input: {
        background: resolve(__dirname, 'src/extension/background.ts'),
        content: resolve(__dirname, 'src/extension/content.ts')
      },
      output: {
        format: 'umd'
      }
    }
  }
})

When I run vite build, it reports a error:

Invalid value "umd" for option "output.format" - UMD and IIFE output formats are not supported for code-splitting builds.

Suggested solution

I can run vite several times to fix it, but I think there's a better solution: rollup/rollup#2935

Alternative

No response

Additional context

No response

Validations

@bluwy
Copy link
Member

bluwy commented Mar 27, 2022

Is this for library mode? There's #7047 to achieve it. Otherwise you can try to set output.inlineDynamicImports: true to fix this (I think). It also seems like you're building a browser extension. Perhaps you can reference https://github.com/antfu/vitesse-webext

@ruofee
Copy link
Author

ruofee commented Mar 27, 2022

Is this for library mode? There's #7047 to achieve it. Otherwise you can try to set output.inlineDynamicImports: true to fix this (I think). It also seems like you're building a browser extension. Perhaps you can reference https://github.com/antfu/vitesse-webext

This PR is what I want!

Setting output.inlineDynamicImports does not fix the problem. But i will reference vitesse-webext. It's like a solution that runs vite several times.

Thank you!

@ruofee ruofee closed this as completed Mar 27, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants