vite-plugin-babel-core-transform
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

vite-plugin-babel-core-transform

A plugin for vitejs to use transform of @babel/core

Getting started

Installation

npm install vite-plugin-babel-core-transform

Usage

Read the details of babel's TransformOptions in https://babel.dev/docs/en/options

// vite.config.js
import { defineConfig } from 'vite';
import babelCoreTransformPlugin from 'vite-plugin-babel-core-transform';

export default defineConfig({
  plugins: [
    babelCoreTransformPlugin((id) => {
      if (/\.(ts|tsx)$/.test(id)) {
        return {
          babelrc: false,
          parserOpts: { plugins: ['jsx', 'typescript'] },
          plugins: [
            [
              'babel-plugin-react-css-modules',
              {
                autoResolveMultipleImports: true,
                generateScopedName,
                exclude: "node_modules",
                filetypes: {
                  '.scss': {
                    syntax: 'postcss-scss',
                  },
                },
              },
              ...
            ]
          ],
          ...
        }
      }
    })
  ]
});

Package Sidebar

Install

npm i vite-plugin-babel-core-transform

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

5.47 kB

Total Files

9

Last publish

Collaborators

  • hooriza