1. babel-preset-vue
Babel preset for all Vue plugins.
babel-preset-vue
Package: babel-preset-vue
Created by: egoist
Last modified: Sun, 13 Nov 2022 06:08:11 GMT
Version: 2.0.2
License: MIT
Downloads: 321,467
Repository: https://github.com/egoist/babel-preset-vue

Install

npm install babel-preset-vue
yarn add babel-preset-vue

babel-preset-vue

Babel preset for all Vue plugins.

Install

 npm install -D babel-preset-vue

CDN: UNPKG

Usage

In your .babelrc:

 {
  "presets": ["vue"]
}

You can toggle specific features, by default all features are enabled, e.g.:

 {
  "presets": [
    ["vue", {
      "eventModifiers": false
    }]
  ]
}

JSX Features

Note that following features are not available for babel v7 currently, you may disable them if necessary.

Event modifiers

Option name: eventModifiers

Uses babel-plugin-jsx-event-modifier for adding event modifiers support.

Example:

 Vue.component('hello-world', {
  methods: {
    method () {
      console.log('clicked')
    }
  },
  render () {
    return (
      <div>
        <a href="/" onClick:prevent={this.method} />
      </div>
    )
  }
})

v-model

Options name: vModel

Uses babel-plugin-jsx-v-model for adding v-model support.

Example:

 Vue.component('hello-world', {
  data: () => ({
    text: 'Hello World!'
  }),
  render () {
    return (
      <div>
        <input type="text" v-model={this.text} />
        {this.text}
      </div>
    )
  }
})

License

MIT © EGOIST

Dependencies

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin