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

Don't tie mode to NODE_ENV in Webpack config #58

Open
arxpoetica opened this issue May 7, 2018 · 1 comment
Open

Don't tie mode to NODE_ENV in Webpack config #58

arxpoetica opened this issue May 7, 2018 · 1 comment
Labels

Comments

@arxpoetica
Copy link
Member

Was getting the following bug when NODE_ENV was set to staging:

$ sapper build
> Building...
WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.mode should be one of these:
   "development" | "production" | "none"

In other words, mode is not vis-a-vis the same as NODE_ENV in Webpack land. So this won't fly:

const mode = process.env.NODE_ENV;

Gosh. 🙃

We could in theory do something like the following:

const mode = process.env.NODE_ENV === 'production' ? 'production' : 'development';

But that's pretty limiting. CLI option? ENV var? https://webpack.js.org/concepts/mode/ mentions passing as config:

webpack --mode=production
@WraithKenny
Copy link

Alternatively,

"scripts": {
    "dev": "sapper dev",
    "build": "NODE_ENV=production sapper build",
    "export": "NODE_ENV=production sapper export",
}

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

No branches or pull requests

2 participants