You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Google App Scripts do not support ES6 imports
which causes issues when trying to push the typescript files directly.
They recommend using
rollup to package every file into a single file to get rid of imports.
We introduce roll-up as a new compilation step and update the README
accordingly.
The setting for sourcemap is moved from tsconfig to rollup.config.js
as using tsc sourcemap with rollup does not work.
task-3329768
We use [rollup.js](https://github.com/rollup/rollup) to package all of the source files into a single one.
22
+
This is necessary as App Scripts do not support ES6 import/export statements yet.
23
+
24
+
Once you have applied the necessary changes, run the following command:
25
+
> npx rollup -c
26
+
27
+
This will simultaneously compile and package the typescript sourcecode inside `build/main.js`
28
+
29
+
Now all you need to do is upload the script to your account and deploy it!
30
+
31
+
## Uploading method 1: Manually copying the file
32
+
If you do not plan on updating this script regularly, perhaps you will prefer using Google's GUI.
33
+
34
+
- Head to [the App Scripts manager](https://script.google.com/) and create a project
35
+
- Go to the project settings and enable appscript.json editing: `Show "appsscript.json" manifest file in editor`
36
+
- Copy the contents of your local `appscript.json` to the remote one in the project editor
37
+
- Create a file `main.gs` and remove the existing `Code.gs` if any.
38
+
- Copy the contents of your local `build/main.js` to the `main.gs` file in the project editor
14
39
15
-
Project dependencies
16
-
> npm install --dev @types/google-apps-script
40
+
## Uploading method 2: Using Clasp
41
+
You may want to use the Google's CLI tool [clasp](https://github.com/google/clasp) to manage, compile and update your app script.
42
+
43
+
First install
44
+
> npm install -g @google/clasp
17
45
18
-
## Clasp
19
46
Login to your account to be able to push on your Gmail project,
20
-
> clasp login --no-localhost
47
+
> clasp login
21
48
22
-
Open your Gmail project
23
-
> clasp open
49
+
Note: the `--no-localhost` option we previously recommended was [deprecated by google](https://developers.google.com/identity/protocols/oauth2/resources/oob-migration)
24
50
25
-
Enable the Gmail API
26
-
> clasp apis enable gmail
51
+
### If you already have a project
52
+
Update `.clasp.json` to use your own script id and project.
53
+
If you do not have a specific project, use `Default`.
27
54
28
-
Automatically push the project when a changed is detected
29
-
> clasp push --watch
55
+
### If you do not have a project yet
56
+
Remove `.clasp.json`
30
57
31
-
## Prettier
32
-
You should auto-format the code using the prettier configuration,
0 commit comments