GitHub Repo: vue-template-babel-compiler
Use Babel to Vue.js SFC enable Optional Chaining(?.)
, Nullish Coalescing(??)
and many other new ES syntax.
Example
characteristic
- All functions of vue-template-compiler && vue-template-es2015-compiler
- New syntax:
Optional Chaining
,Bigint
,nullish coalescing
and more - Custom syntax, babel plugins, etc...
usage
1. Installation
npm install vue-template-babel-compiler --save-dev
2. Configuration
1. Vue-CLI
Vue-CLI configuration demo project
// 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.js configuration demo project
// nuxt.config.js
export default {
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
loaders: {
vue: {
compiler: require('vue-template-babel-compiler')
}
},
},
// ...
}
3. Webpack
// your webpack.config.js where config vue-loader
module.exports = {
// ...
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
compiler: require('vue-template-babel-compiler')
}
}
]
}
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。