How can I configure exporting the compiled files to the public folder? #108
Replies: 2 comments 1 reply
-
Alright, of course things start to click right after posting a question like this... To anyone else stumbling upon this, the answer was to include the files in vite config file. In my case, it was as following:
|
Beta Was this translation helpful? Give feedback.
-
Looks like you've figured it out, but I'm gonna elaborate for anyone else that stumbles across this discussion. Entrypoints, like HTML files and content scripts, end up relative to Vite's root in the final output directory. The plugin itself tries to be as un-opinionated as possible about the directory structure so you can customize it however you like. So lets start there. Personally, I prefer a flat directory structure inside a
With a project structure like this, you can choose where to put your Vite root, // vite.config.ts - root set to .
export default defineConfig({
plugins: [
webExtension({
manifest: "src/manifest.json",
}),
],
});
export default defineConfig({
root: "src",
build: {
outdir: path.resolve("dist"),
emptyOutdir: true,
},
plugins: [
webExtension({
// manifest option defaults to "<viteRoot>/manifest.json", so it can be excluded
}),
],
});
The only files that really matter in the output directory are your entrypoints. The manifest will always be under Personally, I prefer the second configuration, with the vite root set to "src" because it provides a nicer output directory when using a src directory - the extra As for including additional files to be built, you are correct. If you're not going to list the export default defineConfig({
root: "src",
build: {
outdir: path.resolve("dist"),
emptyOutdir: true,
},
plugins: [
webExtension({
additionalInputs: ["dashboard.html"],
}),
],
}); At this point, setting up links between your pages is easy. On your popup, HREFs can be generated using const Popup: React.FC = () => {
return (
<a href={browser.runtime.getURL('/dashboard.html')} target="_blank">Dashboard</a>
);
}
|
Beta Was this translation helpful? Give feedback.
-
First of all, thanks for making this!
I am trying to wrap my head around how I can transpile jsx files to the public folder.
I am having a hard time choosing the right words to explain this, but essentially, what I want to do is:
I can make it work when using only vanilla, since I can just place the files in the right places.
Where can I learn more about how to go about this?
All the best
Beta Was this translation helpful? Give feedback.
All reactions