chrome-extension-cli
chrome-extension-cli copied to clipboard
Use for more ambitious Chrome Extensions...
Is it possible to use this for Chrome Extensions that use more than a single content script? What if I wanted to add an npm package?
I had the same use case and I've just discovered this project. So as far as I understand you can do it.
The idea is all the content scripts you mention in your webpack.config.js
gets merged into one file under the default name contentScript.js
. You can also see that by looking at the build
directory.
If you have multiple content scripts and you want to merge them together, all you need to do is 👇
// webpack.config.js
const config = (env, argv) =>
merge(common, {
entry: {
contentScript: [PATHS.src + '/contentScript1.js', PATHS.src + '/contentScript2.js'], // <--- See the list
background: PATHS.src + '/background.js',
},
devtool: argv.mode === 'production' ? false : 'source-map',
});
Once you build with this config, you'll be able to see in your build
directory that your contentScript1
& contentScript2
were merged into contentScript.js
. Notice that we didn't even touch content_scripts
key in the manifest.json
.