Develop modular JavaScript with import
and export
statements, NPM packages, and dev
and prod
targets. Build to a code.gs
file that is executable in your Google Apps Script project.
-
Clone the repository
git clone https://github.com/NathanielBrewer/gas-rollup-build.git cd gas-rollup-build
-
Install dependencies
npm install
-
Configure Google Apps Script
- Navigate to your Google Apps Script project and open the Project Settings
- Copy the Script ID and paste it into either the
devScriptId
,prodScriptId
, or thescriptId
variable in the .clasp.json file located atsrc/.clasp.json
- Adjust the appscript.json as needed. Documentation available here
-
Develop
- The entry file is
src/code.js
. This gets built tobuild/<target>/code.gs
, which is a runnable Google Apps Script file. - After making changes and any files in the
src/
directory, abuild:<target>
command must be run before those changes will be exectuable by Google Apps Script. - While developing, make your changes and then use
reload:<target>
to run bothbuild:<target>
andpush:<target>
commands.
- The entry file is
-
Build
The build step is required to convert the files into a single Google Script file that can then be pushed and deployed to your Apps Script project.
Command:
npm run build:<target>
where the "target" is either
prod
ordev
-
Push
Invoke
clasp push
for either theprod
ordev
script IDnpm run push:<target>
-
Deploy
Invoke
clasp deploy
for either theprod
ordev
script IDnpm run deploy:<target>
-
Reload
For faster development, build and push in one command
npm run reload:<target>
where the "target" is either
prod
ordev