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

NODE_ENV not being set to production when building #1967

Closed
1 task done
Danktuary opened this issue Oct 19, 2019 · 1 comment · Fixed by #1972
Closed
1 task done

NODE_ENV not being set to production when building #1967

Danktuary opened this issue Oct 19, 2019 · 1 comment · Fixed by #1972
Assignees
Labels
type: feature request Request to add a new feature

Comments

@Danktuary
Copy link

Danktuary commented Oct 19, 2019

  • I confirm that this is an issue rather than a question.

Bug report

The NODE_ENV environment variable is no longer being set to 'production' when running vuepress build docs.

Steps to reproduce

In a VuePress 1.2.0 project:

<!-- docs/README.md -->
# Hi
// docs/.vuepress/config.js
module.exports = { title: process.env.NODE_ENV === 'production' ? 'Prod' : 'Dev' };

After running vuepress build docs and inspecting the index.html file in /docs/.vuepress/dist/, the <title> tag will show Hi | Dev. Inspecting it further:

module.exports = context => {
	console.log(context);
	return { title: process.env.NODE_ENV === 'production' ? 'Prod' : 'Dev' };
};

This is what gets output to the console:
context variable console output

It seems like this repo itself tries to do the same thing I do (set the Algolia docsearch key only in production mode) here: https://github.com/vuejs/vuepress/blob/master/packages/docs/docs/.vuepress/config.js#L34
But it seems like Algolia is also disabled on the live site at this time.

What is expected?

Running vuepress build docs should set the NODE_ENV environment variable to 'production'.

What is actually happening?

The NODE_ENV environment variable isn't being set to 'production'.

Other relevant information

Running NODE_ENV=production vuepress build docs works. The project I was working on was previously running VuePress 0.14.x, so I'm not really sure around what version this started to become an issue.

  • Output of npx vuepress info in my VuePress project:

npx vuepress info

@ulivz
Copy link
Member

ulivz commented Oct 21, 2019

@kefranabg We would need to set the node env after the cli launched, because for now the env will not be set until the webpack process started.

@ulivz ulivz added the type: feature request Request to add a new feature label Oct 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request Request to add a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants