fibonacid
fibonacid
Explore posts from servers
PD🧩 Plasmo Developers
Created by fibonacid on 8/15/2023 in #πŸ”°newbie
Can i integrate plasmo into an existing Vite project or do i have to migrate to Next?
I noticed that there is no with-vite example, why is that? Can i use Vite or is there a major compatibility issue? PS: it might be good to address this in the docs (I apologize if it is actually mentioned, I have not seen it)
1 replies
TTCTheo's Typesafe Cult
Created by fibonacid on 8/15/2023 in #questions
vite app + chrome extension
I'm trying to build a chrome extension that will work along side a traditional Vite app. I'm new to the web extension space and it's a bit overwhelming. There are a lot of plugins and frameworks that claim to be the best approach but they all do the same thing in different ways. I'd like to find a solution that is VERY simple and solves HMR in a reasonably good way. I'm currently considering the simplest approach i could think of, which consist of just adding additional entrypoints in my vite configuration to use the dist folder to contain the app + the web extension files (popup.html, background.js) etc. This is how the application is structured:
.
β”œβ”€β”€ index.html
β”œβ”€β”€ package.json
β”œβ”€β”€ popup.html
β”œβ”€β”€ public
β”‚Β Β  β”œβ”€β”€ manifest.json
β”œβ”€β”€ src
β”‚Β Β  β”œβ”€β”€ app
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ App.tsx
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ main.tsx
β”‚Β Β  β”‚Β Β  └── vite-env.d.ts
β”‚Β Β  └── extension
β”‚Β Β  β”œβ”€β”€ background.ts
β”‚Β Β  └── popup.tsx
β”œβ”€β”€ tsconfig.json
β”œβ”€β”€ tsconfig.node.json
β”œβ”€β”€ vite.config.ts
.
β”œβ”€β”€ index.html
β”œβ”€β”€ package.json
β”œβ”€β”€ popup.html
β”œβ”€β”€ public
β”‚Β Β  β”œβ”€β”€ manifest.json
β”œβ”€β”€ src
β”‚Β Β  β”œβ”€β”€ app
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ App.tsx
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ main.tsx
β”‚Β Β  β”‚Β Β  └── vite-env.d.ts
β”‚Β Β  └── extension
β”‚Β Β  β”œβ”€β”€ background.ts
β”‚Β Β  └── popup.tsx
β”œβ”€β”€ tsconfig.json
β”œβ”€β”€ tsconfig.node.json
β”œβ”€β”€ vite.config.ts
And these are the rollup options that define the entry points:
input: {
main: "./index.html",
popup: "./popup.html",
background: "./src/extension/background.ts",
},
output: {
entryFileNames: "[name].js",
}
input: {
main: "./index.html",
popup: "./popup.html",
background: "./src/extension/background.ts",
},
output: {
entryFileNames: "[name].js",
}
This works, but there is no HMR. To preview a change I need to run vite build. Is there a simple tweak that i can do to improve this?
1 replies