4

vite supports optional Chaining (optional chain judgment operator?.) and nullishCoalescingOperator (null value coalescing operator??)

Install babel optional chain judgment operator, null merge operator compatibility dependency
yarn add @babel/plugin-proposal-optional-chaining --dev

yarn add  @babel/plugin-proposal-nullish-coalescing-operator -dev
vite.config.ts add configuration
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import checker from "vite-plugin-checker";
import vitePluginImp from "vite-plugin-imp";
import path from "path";
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
  return {
    plugins: [
      react({
        babel: {
          plugins: [
            "@babel/plugin-proposal-optional-chaining",
            "@babel/plugin-proposal-nullish-coalescing-operator",
          ],
        },
      }),
    ],
  };
});
vue please use @vitejs/plugin-vue [not tested]

Airmusic
228 声望14 粉丝

了解 vue 源码,k8s。熟悉常用前端框架、库、工具:Vue, Angular,React, Webpack,Gulp 等 了解 node, 熟悉 KOA 熟练使用 Git,熟练 Gitflow 等常见开发实践 注重设计细节和用户体验,有较强的审美和自主设计能力...