A simple to use TypeScript frontend template based on vue3
(Composition API) and bulma
.
This TypeScript template helps you get started with developing Vue 3 applications quickly and easily, and is designed for building mobile friendly web applications with persistent state across sessions.
Get started by
use this template
button on github, and cloning it locally.git
config) and extracting it.git
folder.git
folder to use git yourself!!npm i
npm run serve
npm run lint
npm run preview
npm run typecheck
npm run build
npm run build:full
npm i
after this to get npm to update your package-lock.json
file's name and version too.env
filesVITE_API_URL
to use as the API default base URL if you are not using the ternary method in main.tsbase
property used for demo purposes.TypeScript
as the languagevue3
vue-router
pinia
for state managementpinia-plugin-persistedstate
to persist state across sessions in localStoragebulma
CSS library as the main styling dependencysimpler-fetch
as the API libraryprettier
eslint
, this template is configured to follow the Vue.js style guidegh-pages
is ran using npx when deploying to github pages, and so it will only be temporarily installed if deploying to github pages.# hashed based routing
rather than history modeVSCode + Volar (and disable Vetur) + TypeScript Vue Plugin (Volar).
Please make sure to disable Vetur when using this project in vs code, because with vetur installed, you will face these issues:
<script setup>
block, because it will not be able to understand the setup block and thus think that there is no default export when there is actually..vue
Imports in TSTypeScript cannot handle type information for .vue
imports by default, so we replace the tsc
CLI with vue-tsc
for type checking. In editors, we need TypeScript Vue Plugin (Volar) to make the TypeScript language service aware of .vue
types.
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a Take Over Mode that is more performant. You can enable it by following these steps:
Extensions: Show Built-in Extensions
from VSCode's command paletteTypeScript and JavaScript Language Features
, right click and select Disable (Workspace)
Developer: Reload Window
from the command palette.Reference: https://vuejs.org/guide/typescript/overview.html#takeover-mode
To use Github Pages, ensure that the production base URL is set properly in your vite config file before building and deploying the site.
# Build the site and write build output to ./docs
# The default npm run build writes build output to ./dist
npm run build:gh-pages
# Deploys ./docs folder to github pages
npm run deploy:gh-pages
Github uses jekell to build and deploy your static site to github pages, and so, there are some filenames that are not allowed such as files that start with a period .
or underscore _
which poses a problem as some build output files have underscore characters.
The solution to this is to ensure that a .nojekyll file is placed in the root of the build output directory, which for github pages is ./docs. However, since it is troublesome to always manually create the file after building, a .nojekyll
file is placed in ./public so that it is automatically copied into the root of the build output directory on every build.
References:
Made available with MIT license, created by JJ