fregante / browser-extension-template

📕 Barebones boilerplate with Parcel 2, options handler and auto-publishing
788 stars 76 forks source link

Parcel building files outside of those defined in manifest.json #50

Closed nikoisonfire closed 3 years ago

nikoisonfire commented 3 years ago

It would be great to be able to config parcel to also compile other files in the "/source"-dir such as other used .html/.js files

image

In this example would be redirect.html and redirect.js but they are not compiled to /distribution, only the main files (options.../background...)

nikoisonfire commented 3 years ago

Closing this one myself face-palm. Sometimes I'm too fast to creating issues.

Changed the package.json watch task:

"watch": "parcel watch source/*.js source/*.html source/*.css source/manifest.json --dist-dir distribution --no-cache --no-hmr",

Maybe you want to add this to the documentation? I think could be helpful for some people :)

fregante commented 3 years ago

redirect.html and redirect.js but they are not compiled to /distribution

What are those files? How do you use them?

nikoisonfire commented 3 years ago

My extension on a list of pages (in options) redirects to that redirect.html but I want that page to be able to communicate with my extension (sendMessage --> received in background.js), that's why this redirect.js exists

(in a nutshell: user types in XYZ.com, gets redirect to the HTML, redirect makes the user do some stuff and then redirects back to the XYZ)

Tried to use content-scripts and background-script as .html but both approaches weren't really working for my so I outsourced

fregante commented 3 years ago

"watch": "parcel watch source/*.js source/*.html source/*.css source/manifest.json --dist-dir distribution --no-cache --no-hmr",

Instead of this you can only the files that are not found through manifest.json. In your case:

parcel watch source/manifest.json source/redirect.*

Including every JS and CSS file that's already included might cause issues in Parcel’s dependency resolution.