Skip to content

Commit

Permalink
feat(Start): Add initialPath param to config (#141)
Browse files Browse the repository at this point in the history
Allow an initial path to be set so a specific route can be set when running sku start
  • Loading branch information
georgespyropoulos committed Jun 28, 2018
1 parent 45db925 commit 4d1767b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -332,7 +332,9 @@ module.exports = {
// A list hosts your app can run off while in the dev environment.
hosts: ['dev.seek.com.au', 'dev.seek.co.nz'],
// The port you want the server to run on
port: 5000
port: 5000,
// Optional parameter to set a page to open when the development server starts
initialPath: '/my-page'
}
```

Expand Down
5 changes: 3 additions & 2 deletions config/builds.js
Expand Up @@ -47,8 +47,8 @@ const builds = buildConfigs
const locales = buildConfig.locales || [''];
const compilePackages = buildConfig.compilePackages || [];
const hosts = buildConfig.hosts || ['localhost'];

const port = buildConfig.port || 8080;
const initialPath = buildConfig.initialPath || '/';

const polyfills = buildConfig.polyfills || [];

Expand Down Expand Up @@ -84,7 +84,8 @@ const builds = buildConfigs
eslintDecorator,
hosts,
port,
polyfills
polyfills,
initialPath
};
});

Expand Down
4 changes: 2 additions & 2 deletions scripts/start-ssr.js
Expand Up @@ -6,7 +6,7 @@ const opn = require('opn');
const Promise = require('bluebird');
const webpackPromise = Promise.promisify(require('webpack'));
const fs = require('fs-extra');
const { hosts, port } = builds[0];
const { hosts, port, initialPath } = builds[0];
const serverEntry = builds[0].paths.serverEntry;

const compiler = webpack(serverEntry ? webpackConfig[0] : webpackConfig);
Expand Down Expand Up @@ -62,7 +62,7 @@ const copyPublicFiles = () => {
runWebpack(webpackConfig[1])
.then(copyPublicFiles)
.then(() => {
const url = `http://${hosts[0]}:${port.backend}`;
const url = `http://${hosts[0]}:${port.backend}${initialPath}`;
console.log(`Starting the back-end development server on ${url}...`);
if (process.env.OPEN_TAB !== 'false') {
opn(url);
Expand Down
4 changes: 2 additions & 2 deletions scripts/start.js
Expand Up @@ -4,7 +4,7 @@ const webpackConfig = require('../config/webpack/webpack.config');
const builds = require('../config/builds');
const opn = require('opn');

const { hosts, port } = builds[0];
const { hosts, port, initialPath } = builds[0];

const compiler = webpack(webpackConfig);
const devServer = new WebpackDevServer(compiler, {
Expand All @@ -20,7 +20,7 @@ devServer.listen(port, '0.0.0.0', (err, result) => {
return console.log(err);
}

const url = `http://${hosts[0]}:${port}`;
const url = `http://${hosts[0]}:${port}${initialPath}`;

console.log();
console.log(`Starting the development server on ${url}...`);
Expand Down

0 comments on commit 4d1767b

Please sign in to comment.