1. @vue/babel-preset-jsx
Babel preset for Vue JSX
@vue/babel-preset-jsx
Package: @vue/babel-preset-jsx
Created by: vuejs
Last modified: Thu, 25 Aug 2022 11:55:09 GMT
Version: 1.4.0
License: MIT
Downloads: 3,836,644
Repository: https://github.com/vuejs/jsx

Install

npm install @vue/babel-preset-jsx
yarn add @vue/babel-preset-jsx

@vue/babel-preset-jsx

Configurable preset for Vue JSX plugins.

Babel Compatibility Notes

Usage

Install the dependencies:

 # for yarn:
yarn add @vue/babel-preset-jsx @vue/babel-helper-vue-jsx-merge-props
# for npm:
npm install @vue/babel-preset-jsx @vue/babel-helper-vue-jsx-merge-props --save

In your babel.config.js:

 module.exports = {
  presets: ['@vue/babel-preset-jsx'],
}

You can toggle specific features, by default all features (except compositionAPI) are enabled, e.g.:

 module.exports = {
  presets: [
    [
      '@vue/babel-preset-jsx',
      {
        vModel: false,
        compositionAPI: true,
      },
    ],
  ],
}

Options are:

  • compositionAPI - Enables @vue/babel-sugar-composition-api-inject-h and @vue/babel-sugar-composition-api-render-instance, support returning render function in setup.
    • The default value is false;
    • When set to 'auto' (or true), it will detect the Vue version in the project. If it's >= 2.7, it will import the composition utilities from vue, otherwise from @vue/composition-api;
    • When set to 'native' (or 'naruto'), it will always import the composition utilities from vue
    • When set to plugin, it will always import the composition utilities from @vue/composition-api, but it will redirect to 'vue' itself when the vue version is 2.7.x
    • When set to vue-demi, it will always import the composition utilities from vue-demi
    • When set to an object like { importSource: string; }, it will always import the composition utilities from the importSource you set
  • functional @vue/babel-sugar-functional-vue - Functional components syntactic sugar
  • injectH @vue/babel-sugar-inject-h - Automatic h injection syntactic sugar
  • vModel @vue/babel-sugar-v-model - vModel syntactic sugar
  • vOn @vue/babel-sugar-v-on - vOn syntactic sugar

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