How to exclude some code when building for production? #3110
-
I am using and importing msw library in my code as an es module in development mode & I am using |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
I'm doing it like this to exclude msw from the production bundle: // index.tsx
async function prepare() {
if (import.meta.env.DEV) {
const { worker } = await import('./mocks/browser');
return worker.start();
}
}
prepare().then(() => {
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
}); |
Beta Was this translation helpful? Give feedback.
-
How do you do this in case of export statements. I'm in need of excluding the export of POST function during production in a svelte endpoint.
|
Beta Was this translation helpful? Give feedback.
@samadadi
I'm doing it like this to exclude msw from the production bundle: