- Check if your Node.js version is >= 14.
- Update the environment file
- Run
yarn install
to install the dependencies. - Run
git submodule update --init --recursive
- Run
yarn start
- Load your extension on Chrome following:
- Access
chrome://extensions/
- Check
Developer mode
- Click on
Load unpacked extension
- Select the
build
folder.
- Access
All your extension's code must be placed in the src
folder.
The boilerplate is already prepared to have a popup, an options page, a background page.
Some variables needed for building extension are bundled in the env file. Two of them you will need to produce, signup on windscribe with an account
and use the credentials from that account here for the build password and username
. This is needed to fetch locations at build time and embed generated content scripts.
REACT_APP_REDUX_PORT=WS_BROWSER_EXTENSION_STORE
BROWSER=Chrome
API_URL=windscribe.com
BACKUP_API_URL=totallyacdn.com
NODE_ENV=production
BUILD_USER_NAME=
BUILD_USER_PASSWORD=
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, but you need to exclude these entry points from hot reloading (why?). 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:
{
…
entry: {
myContentScript: "./src/js/myContentScript.js"
},
chromeExtensionBoilerplate: {
notHotReload: ["myContentScript"]
}
…
}
and on your src/manifest.json
:
{
"content_scripts": [
{
"matches": ["https://www.google.com/*"],
"js": ["myContentScript.bundle.js"]
}
]
}
Thanks to @hudidit's kind suggestions, this boilerplate supports chrome-specific intelligent code completion using @types/chrome.
After the development of your extension run the command
$ NODE_ENV=production npm run build
Now, the content of build
folder will be the extension ready to be submitted to the Chrome Web Store. Just take a look at the official guide to more infos about publishing.
To run e2e tests locally you need:
- Got to https://www-staging.windscribe.com/signup and create your test user on staging environment
- Save your Username and Password
- Ask guys in qa or web-team channel to upgrade your test user to Pro
- Create
.env.local
file in a root of the project and paste environment variables in it:
REACT_APP_REDUX_PORT=WS_BROWSER_EXTENSION_STORE
BROWSER=Chrome
API_URL=staging.windscribe.com
TEST_USER_NAME=your_username
TEST_USER_PASSWORD=your_password
BUILD_USER_NAME=
BUILD_USER_PASSWORD=
- Run tests by
$ yarn run test:local
It opens a browser window, makes stuff, and closes it automatically. Please, don't interrupt test scenarios by pressing keys or clicking or whatever.