I'm trying to convert default Vite template JS with Babel/preset-env, to be compatible with older browsers - to es2015. In code generated by Vite still appear const instead of var.
I'm using this plugin - https://github.com/owlsdepartment/vite-plugin-babel
My config file looks like the following:
import { defineConfig } from "vite";
import babel from "vite-plugin-babel";
export default defineConfig({
plugins: [
babel({
babelConfig: {
babelrc: false,
configFile: false,
presets: ["@babel/env"]
},
}),
],
server: {
host: "127.0.0.1", // I couldn't load site with localhost
}
});
I can see, that on calling npm run build plugins declared above are loaded. I then get only 2 files inside dist folder instead of 4, which were generated when i didn't use any configuration.
I've tried to achieve this installing the following packages:
•npm create vite@latest - with VanillaJS
•npm install -D vite-plugin-babel
•npm install -D @babel/preset-env
I've also installed @babel/plugin-transform-block-scoping, and tried to add this as plugin - but so far as I know, I shouldn't need it if preset-env is used, but i'm still getting const instead of var in transpiled version.
I've also tried to set vite option build.target to es2015, but it also didn't help.
I've tried to transpile Javascript into ~ES2015/ES5 integrated with Vite