Another style of writing Vue components.
Why this ?
There are many discussions in community that hopes for a solution that supports writing multiple Vue components in a single file. That's why Vue Vine
was born.
Vue Vine
was designed to provide more flexibility of managing Vue components. It is a parallel style to SFC.
Take a quick view:
Package | Version | Description |
---|---|---|
@vue-vine/compiler | Compiler | |
@vue-vine/language-server | Language Server | |
@vue-vine/language-service | Language Service | |
@vue-vine/vite-plugin | Vite Plugin | |
@vue-vine/eslint-parser | ESLint Parser | |
@vue-vine/nuxt | Nuxt Module | |
vue-vine-tsc | TypeScript CLI checker |
# If you didn't install `@antfu/ni` yet, I highly recommend you to install it.
ni -D vue-vine
Use the plugin in vite.config.ts
:
import { VineVitePlugin } from 'vue-vine/vite'
export default defineConfig({
plugins: [
// ...Other plugins
VineVitePlugin()
],
})
Then add macro's type definition in tsconfig.json
:
{
"compilerOptions": {
"types": ["vue-vine/macros"]
}
}
For ESLint, install our custom ESLint parser:
ni -D @vue-vine/eslint-parser
You need to set custom ESLint parser for .vine.ts
files:
// eslint.config.mjs
import antfu from '@antfu/eslint-config'
import * as VueVineESLintParser from '@vue-vine/eslint-parser'
export default antfu(
{
// Override antfu's settings here:
// - ESLint Stylistic is not supported yet
stylistic: false,
},
{
rules: {
// ... Customize rules here
},
},
{
files: [
'path/to/**/*.vine.ts',
],
languageOptions: {
parser: VueVineESLintParser,
},
rules: {
// ... Customize rules here
},
},
)
Finally, install the VSCode extension, search Vue Vine
in the marketplace.
![image](https://private-user-images.githubusercontent.com/46062972/317320203-d86867d3-5a63-4541-b318-f5543f90cf0e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NjgzNTIsIm5iZiI6MTczODk2ODA1MiwicGF0aCI6Ii80NjA2Mjk3Mi8zMTczMjAyMDMtZDg2ODY3ZDMtNWE2My00NTQxLWIzMTgtZjU1NDNmOTBjZjBlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA3VDIyNDA1MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTA2ZjBkMTllNjJmMjk5YWE3MGQ5Mjk0YjhhNDg5NWU5NDE3NGI5MjU2MDZiMDA4YTRjNzFhYTRmYmRjYzQ0ZDEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.nVOATy4kwMunOdeLlhdHKQUekBQq10YA2fD0C9SSAP8)
You can try the demo by following steps:
For development environment setup, first you need to get the VSCode extension bundle ouput.
git clone https://github.com/vue-vine/vue-vine.git
cd vue-vine
pnpm install
# Build all the required packages
pnpm run build
# Build the VSCode extension
pnpm run build:ext
After building the VSCode extension, you can open the 'Debug' tab in VSCode, and start the 'Run Vine Extension' debug session.
![image](https://private-user-images.githubusercontent.com/46062972/259282157-374b77a4-9d49-4eb6-a84b-f7ab64b99bdf.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NjgzNTIsIm5iZiI6MTczODk2ODA1MiwicGF0aCI6Ii80NjA2Mjk3Mi8yNTkyODIxNTctMzc0Yjc3YTQtOWQ0OS00ZWI2LWE4NGItZjdhYjY0Yjk5YmRmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA3VDIyNDA1MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZiYTFkMzcyMWQzMWNhNjBiODNiMWZiNzljMmE1ZTJiNjQxNTE5NjgzYmE4MzI2YTYxYjVmNDU1ZmFlMzVmNzEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.hYd2OO5Bs-Txbk2hOur4q6loCo0mhp1haRG21TnV0ts)
Then start the Playground's dev server in another terminal session.
pnpm run play
- You can see the demo in
http://localhost:3333/
. - You can inspect the transforming process in
http://localhost:3333/__inspect/