Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how can i set three env in the project #702

Closed
dsky1990 opened this issue Jan 30, 2018 · 3 comments
Closed

how can i set three env in the project #702

dsky1990 opened this issue Jan 30, 2018 · 3 comments

Comments

@dsky1990
Copy link

Choose one: is this a 🐛 bug report or 🙋 feature request?

🎛 Configuration (.babelrc, package.json, cli command)

{
  "name": "zhengxian",
  "version": "1.0.0",
  "main": "index.js",
  "repository": "[email protected]:toa-h5/zhengxian.git",
  "license": "MIT",
  "scripts": {
    "dev": "cross-env production=true && parcel index.html ",
    "test": "rm -rf build && parcel build index.html --out-dir testFloder --public-url ./",
    "pro": "rm -rf build && parcel build index.html --out-dir proFloder --public-url ./"
  },
  "browserslist": [
    "iOS >= 5",
    "Android >= 4"
  ],
  "dependencies": {
    "@yzt/native_h5": "^5.3.0",
    "prop-types": "^15.6.0",
    "react": "^16.2.0",
    "react-dom": "^16.2.0"
  },
  "devDependencies": {
    "autoprefixer": "^7.2.5",
    "axios": "^0.17.1",
    "babel-polyfill": "^6.26.0",
    "babel-preset-env": "^1.6.1",
    "babel-preset-react": "^6.24.1",
    "mobx": "^3.4.1",
    "node-sass": "^4.7.2",
    "parcel-bundler": "^1.4.1",
    "postcss-modules": "^1.1.0",
    "react-router": "^4.2.0"
  }
}

🤔 Expected Behavior

I hope if i run yarn run test, i can build file with the config of test , because the url in test is different from production

😯 Current Behavior

i see the cli file , if i have the command build, the NODE_ENV will be set to production,and only development and production in the file , i hope get anothertest

💁 Possible Solution

🔦 Context

💻 Code Sample

🌍 Your Environment

Software Version(s)
Parcel 1.41
Node 8.91
npm/Yarn 1.3.2
Operating System mac ox
@dsky1990
Copy link
Author

why the cli.js need to set the env

if (command.name() === 'build') {
    process.env.NODE_ENV = 'production';
  } else {
    process.env.NODE_ENV = process.env.NODE_ENV || 'development';
  }

set the env from the package.json is a good way

"scripts": {
    "dev": "cross-env NODE_ENV=development parcel index.html --open",
    "test": "rm -rf testFloder && cross-env NODE_ENV=development parcel build index.html --no-minify --out-dir testFloder --public-url ./",
    "pro": "rm -rf proFloder && cross-env NODE_ENV=production parcel build index.html --out-dir proFloder --public-url ./"
  }

@clayrisser
Copy link

Yeah, there are times where I need a development build.

chances added a commit to chances/parcel that referenced this issue Jun 22, 2018
…el-bundler#702

Like others in parcel-bundler#702, there are times when I need a development build. This change remedies that by using the `NODE_ENV` set by a user in the build command, but will default to `production` is none is provided.
@devongovett
Copy link
Member

Fixed by #1600

devongovett pushed a commit that referenced this issue Oct 15, 2018
…#1600)

Like others in #702, there are times when I need a development build. This change remedies that by using the `NODE_ENV` set by a user in the build command, but will default to `production` is none is provided.
devongovett pushed a commit that referenced this issue Oct 15, 2018
…#1600)

Like others in #702, there are times when I need a development build. This change remedies that by using the `NODE_ENV` set by a user in the build command, but will default to `production` is none is provided.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants