Skip to content

Commit 1d123a0

Browse files
Support hot reloading Chrome extension for development purposes (#566)
1 parent 3134728 commit 1d123a0

File tree

11 files changed

+172
-9
lines changed

11 files changed

+172
-9
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ scripts
66
webpack.config.js
77
webpack.prod.js
88
webpack.dev.js
9+
webpack.watch.js
910
src/test
1011
src/models/credentials.ts

.eslintrc.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module.exports = {
22
root: true,
33
parser: '@typescript-eslint/parser',
44
parserOptions: {
5-
"ecmaVersion": 6
5+
"ecmaVersion": 6
66
},
77
plugins: [
88
'@typescript-eslint',
@@ -14,10 +14,10 @@ module.exports = {
1414
],
1515
env: {
1616
"amd": true,
17-
"node": true
17+
"node": true,
1818
},
1919
rules: {
2020
"@typescript-eslint/no-use-before-define": "off",
21-
"@typescript-eslint/explicit-function-return-type": "off"
21+
"@typescript-eslint/explicit-function-return-type": "off",
2222
}
2323
};

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,14 @@ npm install
1515
npm run [chrome, firefox]
1616
```
1717

18+
## Development (Chrome)
19+
20+
``` bash
21+
# install development dependencies
22+
npm install
23+
# compiles the Chrome extension to the `./test/chrome` directory
24+
npm run dev:chrome
25+
# load the unpacked extension from the `./test/chrome/ directory in Chrome
26+
```
27+
1828
Note that Windows users should download a tool like [Git Bash](https://git-scm.com/download/win) or [Cygwin](http://cygwin.com/) to build.

manifests/manifest-chrome-testing.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,5 @@
6565
],
6666
"offline_enabled": true,
6767
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjo5++7m6mlJGqKOnlYehr9tjIqahMZBJUG7PLa7dSRk6bDUu2pVodO1TQWviHlrDTLP+zfoVbDBS8v8cjloK5Tn90nzC6a957dPzOfyC1WUNYNDlGM0BCmZKVP/MWB3d0ffOmTwaxh0L47aLH5nTW0AUmuwCWCBEEl4Acuyp7rwLNGlazBpaom1Qb5ckn29gCJVVVIZ6wudmcrG/FPTNJXQbg8N6wObGrgGOaxmowbkzJmIfKTyHlYOKLAjZ7aJi0W6jsy47/aV+ojvn4gO+ka6BcRhUeWgoQxqEky119f3OWiVP46SJVbAi0pkknThUjDvX11lATGjB5EvJZGyotwIDAQAB",
68-
"content_security_policy": "script-src 'self' 'unsafe-eval'; font-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; connect-src https://www.google.com/ https://*.dropboxapi.com https://www.googleapis.com/ https://accounts.google.com/o/oauth2/revoke https://login.microsoftonline.com/common/oauth2/v2.0/token https://graph.microsoft.com/; default-src 'none'"
68+
"content_security_policy": "script-src 'self' 'unsafe-eval'; font-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; connect-src https://www.google.com/ https://*.dropboxapi.com https://www.googleapis.com/ https://accounts.google.com/o/oauth2/revoke https://login.microsoftonline.com/common/oauth2/v2.0/token https://graph.microsoft.com/ ws://localhost:9090; default-src 'none'"
6969
}

package-lock.json

Lines changed: 115 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "Authenticator generates 2-Step Verification codes in your browser.",
55
"scripts": {
66
"compile": "bash scripts/build.sh firefox",
7+
"dev:chrome": "npm run pretest && webpack --config ./webpack.watch.js",
78
"chrome": "bash scripts/build.sh chrome",
89
"firefox": "bash scripts/build.sh firefox",
910
"prod": "bash scripts/build.sh prod",
@@ -55,6 +56,7 @@
5556
"vue-template-compiler": "^2.6.12",
5657
"webpack": "^4.44.2",
5758
"webpack-cli": "^3.3.11",
59+
"webpack-extension-reloader": "^1.1.4",
5860
"webpack-merge": "^4.2.2"
5961
},
6062
"dependencies": {

scripts/build.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ postCompile () {
8383
if [[ $1 = "chrome" ]]; then
8484
cp manifests/schema-chrome.json $1/schema.json
8585
fi
86-
87-
8886
}
8987

9088
if [[ $PLATFORM = "prod" ]]; then

scripts/test-runner.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ async function runTests() {
3939
ignoreDefaultArgs: ["--disable-extensions"],
4040
args: [
4141
`--load-extension=${path.resolve(__dirname, "../test/chrome")}`,
42+
// prevents zombie Chromium processes from not terminating during development testing
43+
"--single-process",
4244
// for CI
4345
"--no-sandbox",
4446
],

src/test/components/Popup/EntryComponent.ts

Whitespace-only changes.

webpack.dev.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
const path = require("path");
22
const merge = require('webpack-merge');
33
const common = require('./webpack.config.js');
4-
const webpack = require('webpack');
54

65
module.exports = merge(common, {
76
entry: {
8-
test: "./src/test.ts"
7+
test: "./src/test.ts",
98
},
109
module: {
1110
rules: [
@@ -23,7 +22,7 @@ module.exports = merge(common, {
2322
enforce: "post"
2423
}
2524
],
26-
// to supress mocha warnings
25+
// to suppress mocha warnings
2726
exprContextCritical: false,
2827
}
2928
});

0 commit comments

Comments
 (0)