Yes, you can stop esbuild from emitting the CSS file of your server part in your SSR (Server-Side Rendering) app. esbuild allows you to customize the build process through its API, so you have fine-grained control over what gets emitted.

Assuming you are using Node.js with esbuild to bundle your server code and you have a setup similar to the following:

// server.js import { createServer } from 'http'; import { renderToString } from 'react-dom/server'; import App from './App'; const server = createServer((req, res) => { const appHTML = renderToString(<App />); res.end(appHTML); }); server.listen(3000, () => { console.log('Server listening on port 3000'); });

And your build script looks like this:

// package.json { "scripts": { "build:server": "esbuild --bundle server.js --outfile=dist/server.js --platform=node --target=node14" } }

To stop esbuild from emitting the CSS file, you can use the --outdir flag with an empty value. This way, esbuild will bundle the server code but won't emit the CSS file separately.

Update your build script as follows:

// package.json { "scripts": { "build:server": "esbuild --bundle server.js --outfile=dist/server.js --platform=node --target=node14 --outdir=" } }

With this change, esbuild will not create a separate CSS file and will only bundle the server code into dist/server.js. This is useful when you want to avoid serving or including CSS on the server side because SSR typically doesn't require CSS in the server output. The CSS is usually handled separately on the client-side using a tool like webpack or served by a CDN.

Have questions or queries?
Get in Touch