Created
April 24, 2026 11:39
-
-
Save uebayasi/5ab84102f7bc7ebda5bdfe6fc444506c to your computer and use it in GitHub Desktop.
Building GAS script with rslib
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { LibConfig, defineConfig } from '@rslib/core' | |
| export default defineConfig({ | |
| lib: [gasLib(['doGet'])], | |
| source: { | |
| entry: { | |
| index: './src/index.ts', | |
| }, | |
| }, | |
| output: { | |
| copy: [{ from: 'public' }], | |
| }, | |
| }) | |
| // rslib config for GAS | |
| // | |
| // - bundle & build a single dist/Code.js | |
| // - copy public/appsscript.json to dist/appsscript.json | |
| // | |
| // XXX make this a plugin | |
| const UMD_NAME = 'GAS_APP' | |
| function listNames(names: string[]): string { | |
| return names | |
| .map( | |
| (name) => | |
| `function ${name}(...args) { return global["${UMD_NAME}"].${name}(...args); }` | |
| ) | |
| .join('\n') | |
| } | |
| export function gasLib(names: string[]): LibConfig { | |
| return { | |
| format: 'umd', | |
| umdName: UMD_NAME, | |
| syntax: 'es2020', | |
| bundle: true, | |
| output: { | |
| filename: { | |
| js: 'Code.js', | |
| }, | |
| }, | |
| banner: { | |
| js: 'var global = this;', | |
| }, | |
| footer: { | |
| js: listNames(names), | |
| }, | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment