Add flexibility to the start script
Created by: license2e
Description
Instead of just calling openBrowser
, allow developers to pass in a script to kick off the start or open functionality. For example, this would be useful for use with electron development.
Proposed behavior
Inside: packages/react-scripts/scripts/start.js
@@ -279,7 +279,15 @@ function runDevServer(host, port, protocol) {
console.log();
if (isInteractive) {
- openBrowser(protocol + '://' + host + ':' + port + '/');
+ var devUrl = protocol + '://' + host + ':' + port + '/';
+ var startScriptPath = require(paths.appPackageJson).startScript || false;
+ if (startScriptPath) {
+ var path = require('path');
+ process.env.DEV_URL = devUrl;
+ require(path.join(process.cwd(), startScriptPath));
+ } else {
+ openBrowser(devUrl);
+ }
}
});
}
Thoughts?