diff --git a/check-build-env-vars.js b/check-build-env-vars.js new file mode 100644 index 000000000..d1f019238 --- /dev/null +++ b/check-build-env-vars.js @@ -0,0 +1,10 @@ +/* + * SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file) + * + * SPDX-License-Identifier: AGPL-3.0-only + */ + +if (!process.env.REACT_APP_BACKEND_BASE_URL) { + console.error("==============\nREACT_APP_BACKEND_BASE_URL not set.\n Use this task only if you want to create a production build with a real backend. Otherwise use build:mock\n=============="); + process.exit(1); +} diff --git a/package.json b/package.json index 0e10a5009..443f75f1b 100644 --- a/package.json +++ b/package.json @@ -114,7 +114,7 @@ "serve:build": "http-server build/ -s -p 3001 -P \"http://localhost:3001?\"", "build:test": "cross-env REACT_APP_TEST_MODE=true craco build", "build:mock": "cross-env craco build", - "build:production": "bash -c \"[[ -v REACT_APP_BACKEND_BASE_URL ]]\" && (cross-env craco build) || (echo -e '\n==============\nREACT_APP_BACKEND_BASE_URL not set.\nUse this task only if you want to create a production build with a real backend. Otherwise use build:mock\n==============\n'; exit 1)", + "build:production": "(cross-env node check-build-env-vars.js) && (cross-env craco build)", "analyze": "cross-env ANALYZE=true yarn build:mock", "test": "craco test", "lint": "eslint --max-warnings=0 --ext .ts,.tsx src",