Enable Optional Chaining(?.)
, Nullish Coalescing(??)
and many new ES syntax for Vue.js SFC based on Babel.
- All features of vue-template-compiler && vue-template-es2015-compiler
- New ES syntax:
Optional Chaining
,Bigint
,Nullish Coalescing
and more - Use babel to transpile vue render function, customization syntax, babel options customization
npm install vue-template-babel-compiler --save-dev
1. Vue-CLI
// vue.config.js
module.exports = {
chainWebpack: config => {
config.module
.rule('vue')
.use('vue-loader')
.tap(options => {
options.compiler = require('vue-template-babel-compiler')
return options
})
}
}
2. Nuxt.js
// nuxt.config.js
export default {
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
loaders: {
vue: {
compiler: require('vue-template-babel-compiler')
}
},
},
// ...
}
- vue-jest Usage
- Webpack Usage
- Vite Usage
- VueUse &&
<script setup>
Usage - babel options customization
- Functional Component Usage