Skip to content

Commit

Permalink
Updates the README with instructions about the content scripts
Browse files Browse the repository at this point in the history
resolves #4
  • Loading branch information
samuelsimoes committed Dec 31, 2016
1 parent 134acc7 commit a3007b5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,39 @@ You can run the dev mode on other port if you want. Just specify the env var `po
$ PORT=6002 npm run start
```

##Content Scripts

Although this boilerplate uses the webpack dev server, it's also prepared to write all your bundles files on the disk at every code change, so you can point, on your extension manifest, to your bundles that you want to use as [content scripts](https://developer.chrome.com/extensions/content_scripts), but you need to exclude these entry points from hot reloading [(why?)](https://github.com/samuelsimoes/chrome-extension-webpack-boilerplate/issues/4#issuecomment-261788690). To do so you need to expose which entry points are content scripts on the `webpack.config.js` using the `chromeExtensionBoilerplate -> notHotReload` config. Look the example below.

Let's say that you want use the `myContentScript` entry point as content script, so on your `webpack.config.js` you will configure the entry point and exclude it from hot reloading, like this:

```js
{
entry: {
myContentScript: "./src/js/myContentScript.js"
},
chromeExtensionBoilerplate: {
notHotReload: ["myContentScript"]
}
}
```

and on your `src/manifest.json`:

```json
{
"content_scripts": [
{
"matches": ["https://www.google.com/*"],
"js": ["myContentScript.bundle.js"]
}
]
}

```

##Packing
After the development of your extension run the command

Expand Down
3 changes: 2 additions & 1 deletion utils/webserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ var WebpackDevServer = require("webpack-dev-server"),

require("./prepare");

var excludeEntriesToHotReload = (config.excludeEntriesToHotReload || []);
var options = (config.chromeExtensionBoilerplate || {});
var excludeEntriesToHotReload = (options.notHotReload || []);

for (var entryName in config.entry) {
if (excludeEntriesToHotReload.indexOf(entryName) === -1) {
Expand Down

0 comments on commit a3007b5

Please sign in to comment.