sapper-template icon indicating copy to clipboard operation
sapper-template copied to clipboard

Don't tie `mode` to `NODE_ENV` in Webpack config

Open arxpoetica opened this issue 7 years ago • 1 comments

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

arxpoetica avatar May 07 '18 08:05 arxpoetica

Alternatively,

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

WraithKenny avatar Sep 06 '19 18:09 WraithKenny