I'm trying to set up my environment so when I click run in Visual Studio 2015 it will install my node modules, and then run the front-end webpack-dev-server.
I added
"precompile": [ "yarn install", "yarn run start" ]
to my scripts
in my project.json
If you want to see the Start Script that I'm running: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/scripts/start.js
It works, kinda. It will start the server, but doesn't open it in the browser, and it kinda breaks VS to the point where I can't stop debugging, and can't close VS because it's debugging.
So is there anyway I can make this work the way I want it to, or should I just resort to using cmd to start the webpack-dev-server?
I just tried:
"precompile": [ "yarn install", "start cmd /k yarn run start" ]
hoping I could get VS to open a command prompt and run the start script, but that didn't work.
I found an answer. Going to keep this open to see if anyone has a better solution.
In my Startup.cs I added:
Process.Start("CMD.exe", "/K yarn run start"); Process.Start("cmd", "/C start http://localhost:3000");
The first line running my command in cmd, and the second opening my default browser at the port of my webpack-dev-server.
A second solution that may work depending on the use case.
Download the node tools for VS and create a new empty Node project in your solution. You can go to the project's properties and there's an input called Script (startup file)
. You can point that to your start up script, in my case it was scripts/start.js
1 Answers
Answers 1
Here's the solutions that I came up with:
In my Startup.cs I added:
Process.Start("CMD.exe", "/K yarn run start"); Process.Start("cmd", "/C start http://localhost:3000");
The first line running my command in cmd, and the second opening my default browser at the port of my webpack-dev-server.
A second solution that may work depending on the use case.
Download the node tools for VS and create a new empty Node project in your solution. You can go to the project's properties and there's an input called
Script (startup file)
. You can point that to your start up script, in my case it wasscripts/start.js
0 comments:
Post a Comment