Support WebExtensions manifest.json

🙋 feature request

🤔 Expected Behavior

Parcel takes a manifest.json (not to be confused with normal web app manifest.json) as the entry point, and handles the assets (HTML, JS, CSS, image files) defined in there. It copies them, as well as referenced assets inside, to ./dist. Of course, assets will be processed if necessary, i.e., TS to JS, LESS to CSS.

😯 Current Behavior

Parcel only copies the manifest.json to ./dist.

💁 Possible Solution

Implements a new Asset handler for this.

🔦 Context

When developing an extension for browsers, there are many different files in different places, i.e., background/index.ts, popup/index.html, devtools/index.html, images/icon32.png, inject/inject.less…. However, they are all defined in the main manifest.json, which makes it suitable for being the entry point.

Besides, Parcel does not handle multiple entry points nicely, yet.

2 thoughts on “Support WebExtensions manifest.json

  1. That’s not really needed. Parcel works quite well with extensions when manually given the paths to build + using cpx to copy the assets (including manifest.json):

    	"scripts": {
    		"dev:parcel": "parcel --no-autoinstall --port 9090 --no-hmr src/**/*.html src/background/background.ts src/content-scripts/*.ts",
    		"dev:cpx": "cpx 'src/**/*.{json,png,svg}' dist --watch --verbose",
    		"dev": "npm-run-all  clean  --parallel dev:parcel dev:cpx",
    
    		"build:parcel": "parcel build --no-minify src/**/*.html src/background/background.js src/content-scripts/*.js --public-url ./",
    		"build:cpx": "cpx 'src/**/*.{json,png,svg}' dist",
    		"build:extension": "run-s  build:parcel  build:cpx",
       }

    Parcel really makes developing webextensions a breeze. Many thanks to the authors!