gas-lighter
AI Summary
@battis/gas-lighter
A library that bundles build configurations and common code for TypeScript-based Google Apps Script projects to eliminate boilerplate.
Target Users
Intermediate to advanced developers who build multiple TypeScript-based GAS projects and want to shorten repetitive setup tasks.
Problems Solved
Each time a developer writes GAS in TypeScript, manually configuring tsconfig, Webpack, ESLint and Clasp integration is tedious and error-prone.
Tags
Main Features
Standardized build setup
Provides ready-made tsconfig and Webpack settings that can be adopted with a single `extends` or require line.
Boilerplate reduction
Centralises common settings and helpers via npm so the script itself can focus on business logic.
CLASP integration scripts
Offers example npm scripts like `npm run deploy` that automate the flow from build to `clasp push`.
Consistent ESLint rules
Inheriting the bundled `.eslintrc.json` keeps code-quality rules consistent across projects.
Usage Examples
Add a custom menu with the minimum setup
The snippet below goes into src/index.ts
. Using the tsconfig and Webpack config shipped with @battis/gas-lighter
, it can be built and deployed with the steps in the README.
// src/index.ts
// Adds a custom menu when the Spreadsheet is opened
function onOpen() {
const ui = SpreadsheetApp.getUi(); // Get Spreadsheet UI
ui.createMenu('Sample') // Create menu
.addItem('Say Hello', 'sayHello')
.addToUi();
}
// Function called from the custom menu
function sayHello() {
SpreadsheetApp.getUi().alert('Hello from gas-lighter build!');
}
After saving the file, run npm run deploy
as described in the README. The TypeScript is compiled to build/main.js
and pushed to your GAS project via clasp push
.