With this project your can use Vue3 with Google Sheets as a backend.
Tip
If you want to use a CSS framework like DaisyUI and tailwindcss, you can see my other repo to use it → here.
git clone https://github.com/ilias777/vue3GAS.gitcd vue3GASnpm installRemove the .clasp.json file in the root directory, to create later your own .clasp.json file with your scriptID:
rm .clasp.jsonInstall clasp in your system.
npm install -g @google/clasp- Go to docs.google.com and create a Google Sheets document
- Inside the Sheets document press in the menu bar, under extensions, Apps Script
- A new tab appears with the Google Apps Script code. Copy the script ID (https://script.google.com/macros/s/{scriptID}/edit).
- Press the
Deploybutton, in the upper right corner, to create a web app.
Go to https://script.google.com/home/usersettings and turn on the Google Apps Script API.
clasp loginClone the Sheets script with clasp in the ./gas folder.
clasp clone --rootDir ./gas <scriptID>Move from the ./gas folder the .clasp.json file to the root directory
mv ./gas/.clasp.json .Build the project
npm run buildFrom here your can start build your web application, with Google Sheets as a backend.
If you are finish with your changes in your App, run npm run build to build the project and
a index.html are created in the ./dist folder. Then this file is moved to the ./gas folder
and all the files are pushed to google apps script automatically.
After the files are pushed, refresh the page of the Google Apps Script site, deploy your app again and you are done.
Make a new deployment.
Run in the terminal:
npm run buildThen deploy your app:
clasp create-deployment --description "Message"or
clasp create-deployment -d "Message"Update an existing deployment
First see all deployments:
clasp deploymentsA list appears with your deployments. Copy the ID from your last deployment and add it to the command:
clasp create-deployment -d "Message" -i <deployment-id>To see your Web-App in the browser type:
clasp open-scriptThe script opens in your browser and press "Deploy" - "Manage Deployments". Click in the URL and your app opens in a new tab.
To test your Web-App before deploy it, go first to Google Script page:
clasp open-scriptThe script opens in the browser. Press "Deploy" and then "Test Deployment". Now click the URL to open the Web-App.
The Web-App opens in a new tab.
Keep it open in your browser.
Go to your editor and make the needed changes. If you want to see how it looks, push the files to Google Script:
npm run buildNow go to your browser, reload the page and now all the changes are applied.
With this method you can test your Web-App before creating a new deployment.
These are the steps to reproduce the project:
npm create vue@latestcd <your-project-folder>npm install- Remove content from
./src/App.vue.
<template>
<nav>
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
</nav>
<router-view />
</template>-
Remove content from
./src/assets/main.cssand keep only the first line@import './base.css';In yourbase.cssfile you can add css styles if needed. -
Delete
./src/assets/logo.svgfile. -
Delete all folders and files from
./src/components/folder.
npm install --save-dev vite-plugin-singlefileimport { viteSingleFile } from 'vite-plugin-singlefile'
export default defineConfig({
plugins: [vue(), viteSingleFile()]
})Install clasp in your system, to push the files to Google Apps Script
npm install -g @google/clasp- Go to docs.google.com and create a Google Sheets document
- Inside the Sheets document press in the menu bar, under extensions, Apps Script
- A new tab appears with the Apps Script code. Copy the scriptID.
Sing in to Google from your terminal with clasp.
clasp loginGo to https://script.google.com/home/usersettings and turn on the Google Apps Script API.
More information and the commands can you read in the clasp repo
mkdir gasclasp clone --rootDir ./gas <scriptUrl>mv ./gas/.clasp.json .clasp pull
Now you have in your ./gas folder a Code.js file
function doGet(e) {
return HtmlService.createTemplateFromFile('index.html')
.evaluate()
.addMetaTag('viewport', 'width=device-width, initial-scale=1.0')
.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL)
.setTitle('Vue3 GAS')
}clasp pushnpm install --save-dev @types/google-apps-scriptnpm run buildCopy ./dist/index.html file to ./gas folder
cp ./dist/index.html ./gas"scripts": {
"build": "vite build && mv ./dist/index.html ./gas && clasp push",
}Every change is saved in the ./dist/index.html file. With the command npm run build the index.html file is copied in the ./gas
folder and pushed to google apps script automatically.