4

vite 支持optional Chaining(可选链判断运算符 ?.)和 nullishCoalescingOperator (空值合并运算符 ??)

安装 babel 可选链判断运算符,空值合并运算符 兼容依赖
yarn add @babel/plugin-proposal-optional-chaining --dev

yarn add  @babel/plugin-proposal-nullish-coalescing-operator -dev
vite.config.ts 添加配置
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 请使用 @vitejs/plugin-vue [未测试]

Airmusic
228 声望14 粉丝

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