question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Building with esbuild minifier produces the same css twice

See original GitHub issue

⚠️ IMPORTANT ⚠️ Please check the following list before proceeding. If you ignore this issue template, your issue will be directly closed.

  • Read the docs.
  • Use Vite >=2.0. (1.x is no longer supported)
  • If the issue is related to 1.x -> 2.0 upgrade, read the Migration Guide first.

Describe the bug

When building with minify: 'esbuild', production code has the same CSS twice. One in a js chunk, and the second one in css chunk.

Reproduction

  1. create project with vue-ts template npm init @vitejs/app esbuild-bug --template vue-ts
  2. update vite.config.ts as follows:
export default defineConfig({
  plugins: [vue()],
  build: {
    minify: 'esbuild'
  }
})
  1. run npm run build
  2. open /dist/assets/index.[hash].js
  3. you will see non-minified CSS
  4. open index.[hash].css
  5. you will see the same css, but minified

System Info

  • vite version: 2.0.1
  • Operating System: MacOS Big Sur 11.2.1
  • Node version: 14.4
  • Package manager (npm/yarn/pnpm) and version: 6.14.4

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Dreamacrocommented, Aug 15, 2021

@sheremet-va it’s still no fixed on the latest vite (v2.4.4)

I use a workaround plugin to make minify: 'esbuild' work correctly

{
    plugins: [
        // other plugin
        {
            name: 'remove-css-in-js',
            enforce: 'post',
            transform (_, id) {
                if (id.endsWith('.scss') || id.endsWith('.css')) {
                    return ''
                }
            },
        },
    ],
    build: {
        minify: 'esbuild',
    },
}
1reaction
Dreamacrocommented, Jun 3, 2021

it happened again after 91eb2a6 🌚

Read more comments on GitHub >

github_iconTop Results From Across the Web

API - ESBuild
The build API can take the following options: Simple options: Alias; Bundle; Define; Entry points; External; Format; Inject; Loader; Minify; Outdir; Outfile ...
Read more >
Comparing the New Generation of Build Tools - CSS-Tricks
These new tools aren't designed to perform the exact same function ... Using the “minify” and “bundle” options in your esbuild command won't ......
Read more >
Some notes on using esbuild - Hacker News
Even if it's the same version and I assume the same link, it will bundle it twice and you can get some pretty...
Read more >
Let's talk about esbuild - YouTube
Related Links: esbuild Docs https:// esbuild.github.io/Explain Module Bundlers in 3 Levels of Difficulty https://youtu.be/iOYO2dKBYow00:00 ...
Read more >
rollup.js
rollup.config.js (building more than one bundle) export default [ { input: ... It is bad practice to mix default and named exports in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found