cli: env var definitions for deps optimization in vite
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -132,6 +132,7 @@ DEPRECATION WARNING: React Router Beta is deprecated and support for it will be
|
||||
nodePolyfills: viteNodePolyfills,
|
||||
} = require('vite-plugin-node-polyfills');
|
||||
const { createHtmlPlugin: viteHtml } = require('vite-plugin-html');
|
||||
|
||||
viteServer = await vite.createServer({
|
||||
define: {
|
||||
'process.argv': JSON.stringify(process.argv),
|
||||
@@ -140,6 +141,24 @@ DEPRECATION WARNING: React Router Beta is deprecated and support for it will be
|
||||
// to check for presence of it in source code without module resolution errors.
|
||||
'process.env.HAS_REACT_DOM_CLIENT': JSON.stringify(hasReactDomClient()),
|
||||
},
|
||||
optimizeDeps: {
|
||||
esbuildOptions: {
|
||||
plugins: [
|
||||
{
|
||||
name: 'custom-define',
|
||||
setup(build: {
|
||||
initialOptions: { define: Record<string, string> };
|
||||
}) {
|
||||
const define = (build.initialOptions.define ||= {});
|
||||
define['process.env.HAS_REACT_DOM_CLIENT'] = JSON.stringify(
|
||||
hasReactDomClient(),
|
||||
);
|
||||
define['process.env.NODE_ENV'] = JSON.stringify('development');
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
viteReact(),
|
||||
viteNodePolyfills({
|
||||
|
||||
Reference in New Issue
Block a user