Closed sthzg closed 8 years ago
@sthzg: Thank you, that looks really good to me. Could you please update the README to include this feature? Would be happy to include the pull request for it :)
Great. Just read in the README about the option to run it with a global webpack installation (will check if everything runs as expected that way too).
One thing I am not sure about are the implications for windows users. AFAIK they can't set env variables from the command line (exactly) like that (further they seem to be fragmented to different shells like powershell, cmd, cygwin). Do you have experience with this topic? Otherwise I have a win 7 and win 10 virtualbox, so I could experiment with it a bit.
That was the reason I did it with minimist. I can give the environment via command line parameter in this case ("serve": "node server.js --env=dev"). However, this just "emulates" the real node environment. I usually code on a mac too, so you dont have that problem here. However I know that there are problems with some software systems (like react.js reads the node env so it can assume that it should use the dev or live version).
Will also investigate in this, I got a Win System nearby.
Hm, what do you think about this? It looks promising and as it is officially supported should work cross-platform? A quick test of adding config
shows test variables are correctly exposed:
https://docs.npmjs.com/misc/scripts#configuration
so adding this to package.json
{
//...
"config": {
"devserver_port": 8000,
"testserver_port": 8080
},
// ...
exposes two variables process.env.npm_package_config_devserver_port
and process.env.npm_package_config_testserver_port
. And with npm config set react-webpack-template:devserver_port 12345
the port can be changed.
Update
The one caveat I see is that when installing the react-webpack-generator globally then npm does not read .npmrc
files from within the project directory, but only from the user directory. That again means that setting the value in one project affects the setting globally (not installing the react-webpack-generator globally should "fix" that though).
Basically it seems like a good idea. I will dig into it and look how we could the best results for both plattforms.
Sounds great. For reference I'v added a second commit here to illustrate the later approach e4c0285.
@weblogixx I vote for closing this issue for the time being and possibly renewing it once the new version is stable (I saw that the default port is now in the config, but didn't check whether it's dynamic).
I think so, too. The new version makes it possible to set the port directly in the config, we could also add it to package.json... Will have to think about this.
Sometimes it could be useful to change the ports of the dev or test servers, e.g. by starting them like
I will refer a short commit to this issue. If you find the feature worthwhile it might be a way to implement it.