Skip to content

NODE_ENV not being set to production when building #1967

Closed
@Danktuary

Description

@Danktuary
  • 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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions