Netlify: Show atlas with patches on preview, only build when relevant files changed

This commit is contained in:
Hans5958 2023-07-01 23:53:48 +07:00
parent a19418b02c
commit 6d9cb03d60
2 changed files with 27 additions and 1 deletions

View File

@ -1,6 +1,10 @@
[build]
publish = "dist/"
command = "FILE=tools/ci/build-prod.sh; rm -rf dist/; if [ -f $FILE ]; then bash $FILE; else cp -r web/ dist/; fi"
ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF web/ .parcelrc netlify.toml package-lock.json package.json postcss.config.js"
[build.environment]
PYTHON_VERSION = "3.8"
PYTHON_VERSION = "3.8"
[context.deploy-preview]
command = "FILE=tools/ci/build-preview.sh; rm -rf dist/; if [ -f $FILE ]; then bash $FILE; else cp -r web/ dist/; fi"

22
tools/ci/build-preview.sh Normal file
View File

@ -0,0 +1,22 @@
# This command should be run on CI/Netlify enviroment!
# If you really wanted to run it, run it on the root.
rm -rf dist-temp
rm -rf dist
rm -rf .parcel-cache
cp -r web/ dist-temp/
npm i
python tools/ci/cdn_to_local.py
python tools/ci/merge_out.py # On previews, attempt to merge patches
npx parcel build dist-temp/index.html dist-temp/**.html --dist-dir "dist" --no-source-maps --no-content-hash
rm -rf dist-temp
cp -r web/_img/ dist/
cp web/atlas.json dist/
cp web/*.txt dist/
cp web/_headers dist/
cp web/favicon.ico dist/
cp web/sw.js dist/