Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

fix bugs: #727

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

fix bugs: #727

wants to merge 2 commits into from

Conversation

snovey
Copy link
Contributor

@snovey snovey commented Oct 23, 2018

The value of process.env.NODE_ENV is never set to development in the project.

Only run npm run build will get correct value of process.env.NODE_ENV, other command will get undefined.

I want to lint no-debugger when run npm run lint or npm run build but not lint no-debugger when run npm run dev.(EsLint is going to read the .eslintrc.js file very early on, so to set the value of process.env.NODE_ENV before that, set the value in dev-runner file).

Sorry for my poor English...

1. `process.env.NODE_ENV` get undefined when `npm run lint`
2. won't lint `no-debugger` when `npm run lint`
@@ -1,5 +1,7 @@
'use strict'

process.env.NODE_ENV = 'production'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's right way to fix this bug.

Copy link
Contributor Author

@snovey snovey Nov 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So stupid mistake!
Thank you for reminding me. I have fixed it. Is this the desired result now?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. process.env.NODE_ENV is undefined in .eslintrc.js in development mode, because we are not passing string while linter runs, but for production it reads production as string, it works how it should and .eslintrc.js doesn't need changes.
  2. Highlighted third line in your code, I think is wrong way to pass data for NODE_ENV, you can do it same way as we did for production:
    "pack:renderer": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.renderer.config.js",

    right example:
    cross-env NODE_ENV=development webpack --progress --colors --config .electron-vue/webpack.renderer.config.js

Conclusion:
debugger for development environment already works fine and currently we have only two mode for NODE_ENV: development & production, in most cases NODE_ENV is undefined because we start coding from development and then we separate environment for production.
I hope you understand idea

sorry for my careless
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants