Skip to content

How to expose bundle as window variable? #18192

Closed Answered by mikaelkarlsson-se
mikaelkarlsson-se asked this question in Q&A
Discussion options

You must be logged in to vote

So after some more trial and error and reading of documentation I've finally managed to understand this. There are two ways of doing what I want:

  1. Use Vite lib mode and provide the name property, like this:
lib: {
  entry: "some-entry.ts",
  formats: ["iife"],
  name: "TheName" // -> window.TheName
}
  1. Assign the variable to window yourself 🔧

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@mikaelkarlsson-se
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by mikaelkarlsson-se
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants