Replies: 1 comment
-
figured it out 😊 import { defineConfig, UserConfigFnObject, UserConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { devDependencies } from './package.json';
const viteConfig: UserConfigFnObject = defineConfig(({ mode }) => {
const isProd = mode === 'production';
const isDev = !isProd;
const plugins = isDev
? [react()]
: [
react({
babel: {
presets: [
[
'@babel/preset-env',
{
loose: true,
useBuiltIns: 'entry',
corejs: {
proposals: true,
version: devDependencies['core-js'],
},
modules: false,
},
],
],
},
}),
];
const config: UserConfig = {
plugins: plugins,
};
return config;
});
export default viteConfig;
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm new to vite - so don't judge me harshly 😊
In our project, we use the browserslist to identify the browsers for which we are developing the application.
We focus on certain technologies that we are ready to support, and those browsers that do not fall into this list simply cannot be physically supported due to the lack of necessary support for the necessary APIs and technologies
Our application has a list of browser versions for production:
when building, I see that the "new" browsers are:
at the same time, our list of "old" browsers gets into the list of "new" ones by vite !
We have a question:
how to build a project like the old one (using
babel-preset-env
and automatically applying polyfills to our code without the need to implement unsafe code from third-party resources) but without the need to use both plugins[ react(), legacy()]
(we don't need code for really old browsers - it won't work anyway)?Why not to use
babel-preset-env
when building, which can polyfill and has polyfills with it and saves us from adding another request for polyfills to https://cdnjs.cloudflare.com/polyfill and a potential security threat?Beta Was this translation helpful? Give feedback.
All reactions