FEAT: switch to vite vue stack
This commit is contained in:
105
README.md
105
README.md
@@ -1,54 +1,83 @@
|
||||
# Welcome to [Astro](https://astro.build)
|
||||
# vue-3-stackter
|
||||
|
||||
[](https://stackblitz.com/github/withastro/astro/tree/latest/examples/basics)
|
||||
[](https://codesandbox.io/s/github/withastro/astro/tree/latest/examples/basics)
|
||||

|
||||
|
||||
> 🧑🚀 **Seasoned astronaut?** Delete this file. Have fun!
|
||||
A Vue3 starter project setup with these following components,
|
||||
|
||||

|
||||
- [Vite](https://vitejs.dev/)
|
||||
- vue-meta-3.0.0-alpha.8
|
||||
- Router
|
||||
- [Pinia](https://pinia.vuejs.org/) (Vue 3 default)
|
||||
- Eslint
|
||||
- Prettier
|
||||
- [Tailwind CSS](https://tailwindcss.com/)
|
||||
- File based routing with [vite-plugin-pages](https://github.com/hannoeru/vite-plugin-pages). (Like [Nuxt file system routing](https://nuxtjs.org/docs/2.x/features/file-system-routing))
|
||||
- Layout system with [vite-plugin-vue-layouts](https://github.com/JohnCampionJr/vite-plugin-vue-layouts). (Like [Nuxt layouts](https://nuxtjs.org/docs/2.x/directory-structure/layouts))
|
||||
- Components auto importing with [`unplugin-vue-components`](https://github.com/antfu/unplugin-vue-components)
|
||||
- `~/` alias for `/src`. So we don't have to write something like `../../../SomeModule` to import modules.
|
||||
- and some custom setups.
|
||||
|
||||
[Check out Typescript version here](https://github.com/shamscorner/vitesse-stackter-clean-architect)
|
||||
|
||||
# Deploy :
|
||||
|
||||
node ./dist/server/entry.mjs
|
||||
|
||||
## 🚀 Project Structure
|
||||
|
||||
Inside of your Astro project, you'll see the following folders and files:
|
||||
### Run this project:
|
||||
|
||||
```
|
||||
/
|
||||
├── public/
|
||||
│ └── favicon.svg
|
||||
├── src/
|
||||
│ ├── components/
|
||||
│ │ └── Card.astro
|
||||
│ ├── layouts/
|
||||
│ │ └── Layout.astro
|
||||
│ └── pages/
|
||||
│ └── index.astro
|
||||
└── package.json
|
||||
yarn
|
||||
yarn dev
|
||||
```
|
||||
|
||||
Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name.
|
||||
### Change site name
|
||||
|
||||
There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components.
|
||||
In `App.vue` change the following,
|
||||
|
||||
Any static assets, like images, can be placed in the `public/` directory.
|
||||
```Javascript
|
||||
const siteName = 'Vite App' // add your site name here
|
||||
```
|
||||
|
||||
## 🧞 Commands
|
||||
### Layouts
|
||||
|
||||
All commands are run from the root of the project, from a terminal:
|
||||
You can add layouts in your project if you want. You will find `default.vue` and `404.vue` layout examples in this project. For more details, check out [vite-plugin-vue-layouts](https://github.com/JohnCampionJr/vite-plugin-vue-layouts). (Like [Nuxt layouts](https://nuxtjs.org/docs/2.x/directory-structure/layouts) system).
|
||||
|
||||
| Command | Action |
|
||||
| :--------------------- | :------------------------------------------------- |
|
||||
| `npm install` | Installs dependencies |
|
||||
| `npm run dev` | Starts local dev server at `localhost:3000` |
|
||||
| `npm run build` | Build your production site to `./dist/` |
|
||||
| `npm run preview` | Preview your build locally, before deploying |
|
||||
| `npm run astro ...` | Run CLI commands like `astro add`, `astro preview` |
|
||||
| `npm run astro --help` | Get help using the Astro CLI |
|
||||
### Pages
|
||||
|
||||
## 👀 Want to learn more?
|
||||
You can add pages to your project. You will find some example pages in the `pages` directory (`index.vue`, `about/[name].vue`, and `[...all].vue`). For more details, check out [vite-plugin-pages](https://github.com/hannoeru/vite-plugin-pages). (Like [Nuxt file system routing](https://nuxtjs.org/docs/2.x/features/file-system-routing)).
|
||||
|
||||
Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat).
|
||||
### Meta info
|
||||
|
||||
You can add meta information in your pages. Here is an example,
|
||||
|
||||
```Javascript
|
||||
<script setup>
|
||||
import { useMeta } from 'vue-meta'
|
||||
|
||||
useMeta({
|
||||
title: 'Homepage',
|
||||
})
|
||||
...
|
||||
|
||||
</script>
|
||||
```
|
||||
|
||||
## Recommended IDE Setup
|
||||
|
||||
[VSCode](https://code.visualstudio.com/) + [Vetur](https://marketplace.visualstudio.com/items?itemName=octref.vetur). Make sure to enable `vetur.experimental.templateInterpolationService` in settings!
|
||||
|
||||
### If Using `<script setup>`
|
||||
|
||||
[`<script setup>`](https://github.com/vuejs/rfcs/pull/227) is a feature that is currently in RFC stage. To get proper IDE support for the syntax, use [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar) instead of Vetur (and disable Vetur).
|
||||
|
||||
## Type Support For `.vue` Imports in TS
|
||||
|
||||
Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can use the following:
|
||||
|
||||
### If Using Volar
|
||||
|
||||
Run `Volar: Switch TS Plugin on/off` from VSCode command palette.
|
||||
|
||||
### If Using Vetur
|
||||
|
||||
1. Install and add `@vuedx/typescript-plugin-vue` to the [plugins section](https://www.typescriptlang.org/tsconfig#plugins) in `tsconfig.json`
|
||||
2. Delete `src/shims-vue.d.ts` as it is no longer needed to provide module info to Typescript
|
||||
3. Open `src/main.ts` in VSCode
|
||||
4. Open the VSCode command palette
|
||||
5. Search and run "Select TypeScript version" -> "Use workspace version"
|
||||
|
Reference in New Issue
Block a user