chibat / chrome-extension-typescript-starter

Chrome Extension TypeScript Starter
MIT License
2.39k stars 403 forks source link

Manifest version 3: service worker Webpack vendor.js can't be included #40

Closed rht closed 2 years ago

rht commented 2 years ago

Thank you for building the template. I tried to upgrade my Chrome manifest version to v3. Almost everything works, except that in the manifest.json, I can no longer include multiple js files for the background.service_worker (The replacement for background scripts in v2), and as such, I had to manually do npm run build twice, once, and then the second time with splitChunks in webpack.common.js is commented out so that the background.js contains all the required js stuff without the need of vendor.js.

What would be the solution so that Webpack can make an exception for background.js? Also, do you have any plan to upgrade this repo to v3?

For context, this branch (https://github.com/FantasticoFox/VerifyPage/tree/mv3) contains the last commit which does the migration to v3.

chibat commented 2 years ago

Thank you for the Issue. I tried to upgrade manifest version to v3. It may look something like the following. https://github.com/chibat/chrome-extension-typescript-starter/commit/b52096f7c5b5d1dd1433064c2864da0dfdc9da45#diff-be1efc9241eda827afef933432e3fe2781dd6b9010105cb2c19710fb11e9a56f

rht commented 2 years ago

The splitChunks optimization works like a charm :tada:. Also, I see that <all_urls> in host_permissions supersedes the need to add activeTab in permissions.