I have a project compiled with webpack. There are separate dev & production builds, differentiated by the NODE_ENV
environment variable. For the dev build, another env variable is required: REPO_PATH
.
Is there a way within webpack to check for the presence or absence of REPO_PATH
, throw a custom error and kill the build if it is not set?
My current solution relies of package.json
scripts:
package.json
{
...
"scripts": {
"dev": "if test -z $REPO_PATH; then echo \"Please set REPO_PATH"; exit 0; fi && NODE_ENV=development webpack --progress --hide-modules"
}
}
This works, but isn't ideal, since some of our developers use windows machines and the if/then statement above is specific to unix systems.
It also just seems like something that should be possible with a small plugin or something similar, but I don't know what I'm looking for.