gas-build
v0.0.3
Published
ESBuild plugin and CLI for bundling modern TS/JS code into Google App Script
Keywords
Readme
Gas Build
An ESBuild plugin and simplified CLI for bundling of Google App Script projects from a modern TypeScript / JavaScript codebase.
Installation
npm install -D gas-build esbuildThis installs both the plugin and the CLI. Note that esbuild is declared as a peer
dependency and must be installed separately.
Usage
CLI
This is a preferred method for simple projects with a single entry point.
To build your project, call the gas-build command with the entry point file and the output file:
gas-build src/index.ts --outfile dist/bundle.jsNote that you might have to wrap the command in a package.json script so that the gas-build
is properly recognized:
{
"scripts": {
"build": "gas-build src/index.ts --outfile dist/bundle.js"
}
}Watch mode
The CLI also supports simple watch mode. Enable it by passing the --watch flag:
gas-build src/index.ts --outfile dist/bundle.js --watchPlugin
When the CLI is not sufficient, you can use the plugin directly in your build script.
Define a custom build script, using the esbuild API, and include the gasBuildPlugin.
// filename: build.mjs
import { build } from 'esbuild'
import { gasBuildPlugin } from 'gas-build'
await build({
entryPoints: ['src/index.ts'],
bundle: true,
// make sure there is a single output file
// for the pluging to process
outfile: 'dist/bundle.js',
platform: 'node',
target: 'es2020',
format: 'esm',
plugins: [gasBuildPlugin()],
})Run the build script using node:
node build.mjs