question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

vue-cli should support different NODE_ENV config for Webpack and Vue app

See original GitHub issue

What problem does this feature solve?

I want to see warn logs of components on production build. Almost all warn() calls surrounded with if (NODE_ENV !== 'production') { }.

What does the proposed API look like?

In vue.config.js

{
  ..., 
  appEnv: "different",
  ...
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
alan-lhhycommented, Nov 8, 2018
4reactions
ouzmancommented, Nov 7, 2018

I solved this problem.

In vue.config.js:


module.exports = {
    ...
    chainWebpack: config => {
        if (process.env.NODE_ENV === "production") {
            config.plugin('define')
                .tap(definitions => {
                    definitions[0] = Object.assign(definitions[0], {
                        'process.env': {
                            NODE_ENV: "'production-with-warns'"
                        }
                    });
                    return definitions
                });
        }
    },
    ...
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Modes and Environment Variables - Vue CLI
When running vue-cli-service , environment variables are loaded from all corresponding files. If they don't contain a NODE_ENV variable, it will ...
Read more >
Using Modes and Environment Variables in Vue.js - Medium
With NODE_ENV set to "test" for example, Vue CLI creates a webpack config that is intended to be used and optimized for unit...
Read more >
Using Environment Variables with Vue.js - Stack Overflow
If you use vue cli with the Webpack template (default config), you can create and add your environment variables to a .env file....
Read more >
Custom Build Modes with Vue CLI 3 | Rangle.io
The webpack build mode is controlled by an environment variable called NODE_ENV and changes how the app is built - for instance, whether...
Read more >
How To Use Environment Variables in Vue.js - DigitalOcean
By default, Vue CLI will support three modes: “development”, "test', and “production”. For more information on using environment variables ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found