Skip to content

Commit 31befe1

Browse files
authored
V3: Migrate to Vite (#221)
This is version 3 of the boilerplate, which makes significant changes to the build script and local development tooling. It replaces Webpack with Vite, which required some significant changes to how the local development setup works with Google Apps Script. A new dev-server-wrapper.html file is used as the wrapper app in development, which is a standalone html + js file instead of a React app. This reduces the need for a complex build step for the wrapper app. Instead the file is just copied over for each entrypoing and the file location is changed with a "replace" step. Due to the way Vite works, the html templates are changed a bit to support local development. Vite doesn't easily allow completely separate multiple builds, so some Vite plugins and custom plugins are written to support multiple entrypoints (sidebars/dialogs). The externalization for large packages is now handled in the Vite config instead of a plugin, and by manually adding in the script tags into the index.html templates. Additional changes here: - yarn is now used instead of npm as package manager - eslint configs are updated to support vite - GitHub workflows for tests are updated to use yarn and other minor changes such as node versions and OS. - A VS Code launch.json configuration is provided - Dev wrapper setup has been updated (see above description) - ES Modules (import/export) updated throughout - Unneeded packages supporting webpack configurations are removed. Many packages have been upgraded. NPM scripts have been updated to use yarn. - Removed `import React` due to Vite config. - Added script tags to each template since webpack externalization plugin is no longer used - Added <script type="module" src="./index.jsx"></script> to index.html templates to support Vite local development - Changed src/server/sheets.js to .ts typescript as exemplar - Updated tests to support yarn commands, Vite changes, and listening for Vite stdout triggers. - Add Vite-style tsconfig.json - README is updated
1 parent 5f2012c commit 31befe1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+8328
-35322
lines changed

.eslintrc.json

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
11
{
22
"root": true,
3-
"parser": "@babel/eslint-parser",
4-
"extends": ["airbnb-base", "plugin:prettier/recommended"],
5-
"plugins": ["prettier"],
3+
"extends": [
4+
"airbnb-base",
5+
"plugin:prettier/recommended",
6+
"eslint:recommended",
7+
"plugin:@typescript-eslint/recommended",
8+
"plugin:react-hooks/recommended"
9+
],
10+
"plugins": ["react-refresh", "prettier"],
611
"rules": {
712
"prettier/prettier": "error",
813
"camelcase": "warn",
914
"import/prefer-default-export": "warn",
1015
"import/no-extraneous-dependencies": "warn",
1116
"prefer-object-spread": "warn",
12-
"spaced-comment":"off"
17+
"spaced-comment": "off",
18+
"react-refresh/only-export-components": [
19+
"warn",
20+
{ "allowConstantExport": true }
21+
]
1322
},
1423
"parserOptions": {
1524
"babelOptions": {
1625
"configFile": "./dev/.babelrc"
1726
}
18-
}
27+
},
28+
"env": { "browser": true, "es2020": true },
29+
"ignorePatterns": ["dist", ".eslintrc.json"],
30+
"parser": "@typescript-eslint/parser"
1931
}

.github/workflows/integration-tests-basic.yaml

+10-10
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ jobs:
99
runs-on: ${{ matrix.os }}
1010
strategy:
1111
matrix:
12-
os: [macos-11, macos-latest, windows-latest]
12+
os: [macos-12, macos-13, windows-2022]
1313
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
14-
node-version: [14, 16, 18]
14+
node-version: [18, 20]
1515
timeout-minutes: 8
1616
steps:
17-
- uses: actions/checkout@v2
17+
- uses: actions/checkout@v4
1818
- name: Use Node.js ${{ matrix.node-version }}
19-
uses: actions/setup-node@v2
19+
uses: actions/setup-node@v4
2020
with:
2121
node-version: ${{ matrix.node-version }}
22-
- name: Install packages [npm ci]
23-
run: npm ci
22+
- name: Install packages
23+
run: yarn install
2424
- name: Allow running mkcert on Mac
2525
run: sudo security authorizationdb write com.apple.trust-settings.admin allow
2626
if: runner.os == 'MacOS'
@@ -30,14 +30,14 @@ jobs:
3030
- name: Run mkcert setup [mkcert -install]
3131
run: mkcert -install
3232
if: runner.os == 'MacOS'
33-
- name: Install https cert [npm setup:https]
34-
run: npm run setup:https
33+
- name: Install https cert [yarn setup:https]
34+
run: yarn setup:https
3535
if: runner.os == 'MacOS'
3636
- run: |
3737
mkdir certs
38-
.\test\generate-cert.ps1
38+
.\scripts\generate-cert.ps1
3939
shell: pwsh
4040
if: runner.os == 'Windows'
4141
- name: Run integration tests
42-
run: npm run test:integration
42+
run: yarn test:integration
4343
shell: bash

.github/workflows/integration-tests-extended.yaml

+16-13
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
name: Local integration tests - Extended Version
22

33
on:
4-
push:
4+
pull_request:
5+
branches: [main]
56

67
jobs:
78
extended-integration-test:
89
runs-on: ${{ matrix.os }}
910
strategy:
1011
matrix:
11-
os: [macos-11, macos-latest, windows-latest]
12+
os: [macos-12, macos-13, windows-2022]
1213
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
13-
node-version: [14, 16, 18]
14+
node-version: [18, 20]
1415
timeout-minutes: 11
1516
steps:
16-
- uses: actions/checkout@v2
17+
- uses: actions/checkout@v4
1718
- name: Use Node.js ${{ matrix.node-version }}
18-
uses: actions/setup-node@v2
19+
uses: actions/setup-node@v4
1920
with:
2021
node-version: ${{ matrix.node-version }}
21-
- name: Install packages [npm ci]
22-
run: npm ci
22+
- name: Install packages
23+
run: yarn install
2324
- name: Allow running mkcert on Mac
2425
run: sudo security authorizationdb write com.apple.trust-settings.admin allow
2526
if: runner.os == 'MacOS'
@@ -29,12 +30,12 @@ jobs:
2930
- name: Run mkcert setup [mkcert -install]
3031
run: mkcert -install
3132
if: runner.os == 'MacOS'
32-
- name: Install https cert [npm setup:https]
33-
run: npm run setup:https
33+
- name: Install https cert [yarn setup:https]
34+
run: yarn setup:https
3435
if: runner.os == 'MacOS'
3536
- run: |
3637
mkdir certs
37-
.\test\generate-cert.ps1
38+
.\scripts\generate-cert.ps1
3839
shell: pwsh
3940
if: runner.os == 'Windows'
4041
- name: Add .clasprc.json to home folder
@@ -65,10 +66,12 @@ jobs:
6566
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}
6667
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
6768
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
68-
- name: Build and deploy dev setup [npm run deploy:dev]
69-
run: npm run deploy:dev
69+
- name: Build and deploy dev setup [yarn deploy:dev]
70+
run: yarn deploy:dev
7071
env:
7172
NODE_OPTIONS: '--max_old_space_size=4096'
7273
- name: Run integration tests
73-
run: npm run test:integration:extended
74+
# use ci-reporter to publish failing diff images to s3 bucket
75+
# run: yarn test:integration:extended:ci-reporter
76+
run: yarn test:integration:extended
7477
shell: bash

.npmrc

-1
This file was deleted.

.vscode/launch.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "chrome",
9+
"request": "launch",
10+
"name": "Launch spreadsheet with debugger",
11+
"trace": true,
12+
"sourceMaps": true,
13+
"pauseForSourceMap": false,
14+
"skipFiles": ["**/node_modules/**", "!${workspaceFolder}/**"],
15+
"webRoot": "${workspaceFolder}/src/client",
16+
// Need random open port for logging into spreadsheets:
17+
// https://github.com/microsoft/vscode-js-debug/issues/918
18+
"port": 12345,
19+
}
20+
]
21+
}

0 commit comments

Comments
 (0)