Giter VIP home page Giter VIP logo

Comments (8)

weblogixx avatar weblogixx commented on August 24, 2024

@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 :)

from react-webpack-template.

sthzg avatar sthzg commented on August 24, 2024

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.

from react-webpack-template.

weblogixx avatar weblogixx commented on August 24, 2024

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.

from react-webpack-template.

sthzg avatar sthzg commented on August 24, 2024

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).

from react-webpack-template.

weblogixx avatar weblogixx commented on August 24, 2024

Basically it seems like a good idea. I will dig into it and look how we could the best results for both plattforms.

from react-webpack-template.

sthzg avatar sthzg commented on August 24, 2024

Sounds great. For reference I'v added a second commit here to illustrate the later approach e4c0285.

from react-webpack-template.

sthzg avatar sthzg commented on August 24, 2024

@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).

from react-webpack-template.

weblogixx avatar weblogixx commented on August 24, 2024

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.

from react-webpack-template.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.