Commit abad1b81 authored by omnus's avatar omnus Committed by GitHub

Next.js compliant command for production builds (#2219)

* feat: Vercel compliant command for prod builds

* feat: simplify to a single command, rename command

Also included the script to download assets.

* fix: exclude vercel injected env vars

Vercel injects a number of environment variables, that in some cases can result in run time errors when the app is reading from envs.js. Exclude these.
parent 7184a66f
...@@ -18,6 +18,12 @@ echo "window.__envs = {" >> $output_file; ...@@ -18,6 +18,12 @@ echo "window.__envs = {" >> $output_file;
# Iterate through all environment variables # Iterate through all environment variables
for var in $(env | grep '^NEXT_PUBLIC_' | cut -d= -f1); do for var in $(env | grep '^NEXT_PUBLIC_' | cut -d= -f1); do
# Skip variables that start with NEXT_PUBLIC_VERCEL. Vercel injects these
# and they can cause runtime errors, particularly when commit messages wrap lines.
if [[ $var == NEXT_PUBLIC_VERCEL* ]]; then
continue
fi
# Get the value of the variable # Get the value of the variable
value="${!var}" value="${!var}"
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
"dev:preset": "./tools/scripts/dev.preset.sh", "dev:preset": "./tools/scripts/dev.preset.sh",
"dev:preset:sync": "tsc -p ./tools/preset-sync/tsconfig.json && node ./tools/preset-sync/index.js", "dev:preset:sync": "tsc -p ./tools/preset-sync/tsconfig.json && node ./tools/preset-sync/index.js",
"build": "next build", "build": "next build",
"build:next": "./deploy/scripts/download_assets.sh ./public/assets/configs && yarn svg:build-sprite && ./deploy/scripts/make_envs_script.sh && next build",
"build:docker": "docker build --build-arg GIT_COMMIT_SHA=$(git rev-parse --short HEAD) --build-arg GIT_TAG=$(git describe --tags --abbrev=0) -t blockscout-frontend:local ./", "build:docker": "docker build --build-arg GIT_COMMIT_SHA=$(git rev-parse --short HEAD) --build-arg GIT_TAG=$(git describe --tags --abbrev=0) -t blockscout-frontend:local ./",
"start": "next start", "start": "next start",
"start:docker:local": "docker run -p 3000:3000 --env-file .env.local blockscout-frontend:local", "start:docker:local": "docker run -p 3000:3000 --env-file .env.local blockscout-frontend:local",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment