Skip to content

Add flexibility to the start script #1095

Closed
@license2e

Description

@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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions