Skip to content

Commit

Permalink
Update config to run frontend locally
Browse files Browse the repository at this point in the history
  • Loading branch information
willdurand committed Jan 5, 2021
1 parent 08769d6 commit 4ec8b1b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 45 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ Here are some commands you can run:

| Command | Description |
| --- | --- |
| yarn amo | Start the dev server/proxy (for amo) using data from Docker. _This is not currently working. See [issue-7196][]_. |
| yarn amo:olympia | Start the dev server/proxy (for amo) using data from a local addons-server environment. |
| yarn amo:dev | Start the dev server/proxy (for amo) using data from the dev server (https://addons-dev.allizom.org/) |
| yarn amo:dev-https | Same as `amo:dev` but with HTTPS, available at: https://example.com:3000/. [Read about setting up this environment](docs/moz-addon-manager.md#developing-with-a-local-https-server-recommended) |
| yarn amo:no-proxy | Start the dev server without a proxy (for amo) using data from Docker |
| yarn amo:stage | Start the dev server/proxy (for amo) using data from the staging server (https://addons.allizom.org/) |
| yarn build | Build the app. |
| yarn build-ci | Run the `build` and `bundlesize` npm scripts. |
Expand Down Expand Up @@ -388,6 +387,5 @@ curl https://addons-dev.allizom.org/__version__
- Unit tests with high coverage (aiming for 100%)

[bundlesize]: https://github.com/siddharthkp/bundlesize
[issue-7196]: https://github.com/mozilla/addons-frontend/issues/7196
[jest]: https://jestjs.io/docs/en/getting-started.html
[prettier]: https://prettier.io/
5 changes: 3 additions & 2 deletions bin/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const useHttpsForDev = process.env.USE_HTTPS_FOR_DEV;
const protocol = useHttpsForDev ? 'https' : 'http';

const apiHost = config.get('proxyApiHost', null) || config.get('apiHost');
const frontendHost = `${protocol}://${config.get('serverHost')}:${config.get('serverPort')}`;
const serverPort = parseInt(config.get('serverPort'), 10);
const frontendHost = `${protocol}://${config.get('serverHost')}:${serverPort}`;

log.info(`apiHost: ${apiHost}`);
log.info(`frontendHost: ${frontendHost}`);
Expand Down Expand Up @@ -94,7 +95,7 @@ proxy.on('error', (error, req, res) => {
});

const host = useHttpsForDev ? process.env.SERVER_HOST : 'localhost';
const port = parseInt(config.get('proxyPort', '3333'), 10);
const port = parseInt(config.get('proxyPort'), 10);

log.info(`🚦 Proxy running at ${protocol}://${host}:${port}`);
server.listen(port);
10 changes: 10 additions & 0 deletions config/development-local.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// This config should be used with a local addons-server setup.
module.exports = {
apiHost: 'http://olympia.test',
proxyApiHost: 'http://olympia.test',
proxyPort: 4000,
webpackServerPort: 4001,
mozillaUserId: 10968,
CSP: false,
enableNodeStatics: true,
};
2 changes: 1 addition & 1 deletion config/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = {

enableStrictMode: true,

serverPort: 3000,
serverPort: 3333,
webpackServerHost,
webpackServerPort,
webpackHost,
Expand Down
20 changes: 0 additions & 20 deletions config/uitests.js

This file was deleted.

27 changes: 8 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
"bundlesize": "bundlesize",
"extract-locales": "better-npm-run extract-locales",
"clean": "rimraf './dist/*!(.gitkeep)' './webpack-assets.json' './src/locale/**(!.gitkeep)'",
"amo": "better-npm-run amo",
"amo:dev": "better-npm-run amo:dev",
"amo:dev-https": "better-npm-run amo:dev-https",
"amo:ui-tests": "better-npm-run amo:ui-tests",
"amo:no-proxy": "better-npm-run amo:no-proxy",
"amo:olympia": "better-npm-run amo:olympia",
"amo:stage": "better-npm-run amo:stage",
"amo:ui-tests": "npm run amo:olympia",
"eslint": "eslint .",
"flow": "flow",
"flow:check": "flow check",
Expand Down Expand Up @@ -52,8 +51,11 @@
"NODE_PATH": "./:./src"
}
},
"amo": {
"command": "better-npm-run start-dev-proxy"
"amo:olympia": {
"command": "better-npm-run start-dev-proxy",
"env": {
"NODE_APP_INSTANCE": "local"
}
},
"amo:dev": {
"command": "better-npm-run start-dev-proxy",
Expand All @@ -71,18 +73,6 @@
"WEBPACK_SERVER_HOST": "example.com"
}
},
"amo:ui-tests": {
"command": "better-npm-run start-dev-proxy",
"env": {
"NODE_ENV": "production"
}
},
"amo:no-proxy": {
"command": "better-npm-run start-dev",
"env": {
"PROXY_ENABLED": "false"
}
},
"amo:stage": {
"command": "better-npm-run start-dev-proxy",
"env": {
Expand Down Expand Up @@ -115,8 +105,7 @@
"ENABLE_PIPING": "true",
"NODE_ENV": "development",
"NODE_ICU_DATA": "./node_modules/full-icu",
"NODE_PATH": "./:./src",
"SERVER_PORT": "3333"
"NODE_PATH": "./:./src"
}
},
"node": {
Expand Down

0 comments on commit 4ec8b1b

Please sign in to comment.