Skip to content

Instantly share code, notes, and snippets.

@uebayasi
Created April 24, 2026 11:39
Show Gist options
  • Select an option

  • Save uebayasi/5ab84102f7bc7ebda5bdfe6fc444506c to your computer and use it in GitHub Desktop.

Select an option

Save uebayasi/5ab84102f7bc7ebda5bdfe6fc444506c to your computer and use it in GitHub Desktop.
Building GAS script with rslib
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