Created
April 7, 2018 19:32
-
-
Save samuelsimoes/80f7fe21814fec023008f77730a1623c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/manifest.json b/src/manifest.json | |
index 75bf42f..b35588d 100644 | |
--- a/src/manifest.json | |
+++ b/src/manifest.json | |
@@ -12,5 +12,11 @@ | |
"128": "icon-128.png" | |
}, | |
"manifest_version": 2, | |
- "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'" | |
+ "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'", | |
+ "content_scripts": [ | |
+ { | |
+ "matches": ["https://www.google.com.br/*"], | |
+ "js": ["myContentScript.bundle.js"] | |
+ } | |
+ ] | |
} | |
diff --git a/utils/webserver.js b/utils/webserver.js | |
index 2e1a91f..89825fa 100644 | |
--- a/utils/webserver.js | |
+++ b/utils/webserver.js | |
@@ -2,7 +2,8 @@ var WebpackDevServer = require("webpack-dev-server"), | |
webpack = require("webpack"), | |
config = require("../webpack.config"), | |
env = require("./env"), | |
- path = require("path"); | |
+ path = require("path"), | |
+ ChromeExtensionReloader = require("webpack-chrome-extension-reloader"); | |
var options = (config.chromeExtensionBoilerplate || {}); | |
var excludeEntriesToHotReload = (options.notHotReload || []); | |
@@ -18,7 +19,16 @@ for (var entryName in config.entry) { | |
} | |
config.plugins = | |
- [new webpack.HotModuleReplacementPlugin()].concat(config.plugins || []); | |
+ [ | |
+ new ChromeExtensionReloader({ | |
+ reloadPage: false, | |
+ entries: { | |
+ contentScript: 'myContentScript', | |
+ background: 'background' | |
+ } | |
+ }), | |
+ new webpack.HotModuleReplacementPlugin() | |
+ ].concat(config.plugins || []); | |
delete config.chromeExtensionBoilerplate; | |
diff --git a/webpack.config.js b/webpack.config.js | |
index 8a6b3ba..dc99ede 100644 | |
--- a/webpack.config.js | |
+++ b/webpack.config.js | |
@@ -22,7 +22,11 @@ var options = { | |
entry: { | |
popup: path.join(__dirname, "src", "js", "popup.js"), | |
options: path.join(__dirname, "src", "js", "options.js"), | |
- background: path.join(__dirname, "src", "js", "background.js") | |
+ background: path.join(__dirname, "src", "js", "background.js"), | |
+ myContentScript: "./src/js/myContentScript.js" | |
+ }, | |
+ chromeExtensionBoilerplate: { | |
+ notHotReload: ["myContentScript"] | |
}, | |
output: { | |
path: path.join(__dirname, "build"), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment