admin管理员组

文章数量:1313133

I am trying to get Vite and babel to play nicely together upon running the dev server so I downloaded this Vite plugin.

In my vite.config.ts, I should add:

plugins: [
    babel({
        babelConfig: // what do I put here?
    })
],

I don't know what to put in the babelConfig property. The docs say that I should include the .babelrc or .babelrc.json but what if I have a babel.config.js instead? The reason I have a JS file is because I want to switch off of (or use ternary operators) for process.env.NODE_ENV or other environment variables.

babel.config.js

module.exports = function (api) {
    api.cache(true)

    switch(process.env.NODE_ENV) {
        case: 'docker': 
            return { plugins: [...], presets: [...] }
        case: 'development':
            return { plugins: [...], presets: [...] }
        case: 'stage':
            return { plugins: [...], presets: [...] }
        case: 'production':
        default:
            return { plugins: [...], presets: [...] }
        
    }
}

Any idea on what I should pass to the babel plugin for Vite to use my babel.config.js?

本文标签: babeljsUsing babel plugin in Vite with babelconfigjsStack Overflow