Example
This works, but I have a feeling it could be WAY better! copy:deps is insanely long lol.
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start",
"export": "next export",
"analyze": "cross-env BUNDLE_ANALYZE=both next build",
"analyze:server": "cross-env BUNDLE_ANALYZE=server next build",
"analyze:browser": "cross-env BUNDLE_ANALYZE=browser next build",
"build:functions": "npm run build:functions:lint && cpx \"functions/lib/functions/src/**/*.*\" dist/functions",
"build:functions:lint": "cd functions && npm run lint && npm run build",
"clean": "rimraf dist && rimraf functions/lib && rimraf .next",
"copy:deps": "cpx \"functions/*{package.json,package-lock.json}\" dist/functions && ncp functions/node_modules/ dist/functions/node_modules && cpx \".next/serverless/**/*.*\" dist/functions/_next/serverless/ && cpx \".next/static/**/*.*\" dist/public/_next/static/ && cpx \"static/**/*.*\" dist/public/static && cpx \"dist/functions/_next/static/**/*.*\" dist/public/_next/static && cpx \"dist/functions/_next/serverless/pages/*.html\" dist/public",
"firebase:build": "npm install && npm run clean && npm run build && npm run build:functions && npm run copy:deps",
"firebase:serve": "npm run firebase:build && firebase serve",
"firebase:deploy": "npm run firebase:build && firebase deploy"
},
When should we stop though?
So when is a script too long? I really don't know!
Sometimes I break them up into my cloudbuild.yaml file, which calls another file like this.
# Git the submodules, run npm install, hugo build
- name: 'gcr.io/$PROJECT_ID/hugo'
args: ['bash', './deploy.sh']
Then this fires a lot of what could be done using NPM as well. I moved this one because if I have GCloud run it I don't have to worry about git freak out about logins 🦄!
#!/bin/bash
echo -e "\033[0;32mAdding Submodules...\033[0m"
git submodule init
git submodule update --recursive --remote
echo -e "\033[0;32mInstalling via npm...\033[0m"
npm install
echo -e "\033[0;32mBuilding via npm...\033[0m"
npm run build
Thoughts
So tell me how bad does it get, what is an example that you have??
Top comments (0)