Giter Club home page Giter Club logo

Comments (5)

kentcdodds avatar kentcdodds commented on May 26, 2024 12

Nope, you're fine. This was an ok place to ask the question.

from cross-env.

kentcdodds avatar kentcdodds commented on May 26, 2024 5

cross-env is a CLI that will spawn a process for the command you give it with the environment variables set as you specify in the command.

dotenv will spawn the process with the environment variables based on a .env file.

Both are useful. Depends on your needs.

from cross-env.

xahon avatar xahon commented on May 26, 2024

@kentcdodds why doesn't cross-env allow to source .env file and use it instead of dotenv module?

from cross-env.

KresimirCosic avatar KresimirCosic commented on May 26, 2024

So you're saying that cross-env is literally the same thing from native Webpack's environment variables - as it is in their documentation?

webpack --env.PORT=3000 --env.ENV=development --config webpack.common.js for example, the difference is being in module.exports you don't set it to an object, but to a function which receives an environment object, and you can extract data from there and do logic where necessary:

module.exports = env => {
  // Use env.<YOUR VARIABLE> here:

from cross-env.

kentcdodds avatar kentcdodds commented on May 26, 2024

This project was created years ago. Long before the --env flag existed for webpack. So maybe the examples in the README are dated. But there are still plenty of situations where you'd want to run a script with environment variables set.

from cross-env.

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.