Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Duplicated css in output with v4.2 vs v3.1 #55

Closed
crisward opened this issue Jul 15, 2023 · 4 comments
Closed

Duplicated css in output with v4.2 vs v3.1 #55

crisward opened this issue Jul 15, 2023 · 4 comments

Comments

@crisward
Copy link

crisward commented Jul 15, 2023

After updating to 4.2 I saw a massive increase in bundle size for our css. When checking the content it looks like the css had been added to the output file multiple times.

Dependency Versions

@rollup/plugin-commonjs@17.1.0
@rollup/plugin-json@6.0.0
@rollup/plugin-node-resolve@11.2.1
rollup-plugin-css-only@4.2.0
rollup-plugin-inject-process-env@1.3.1
rollup-plugin-output-manifest@2.0.0
rollup-plugin-svelte@7.1.6
rollup@2.79.1
svelte@3.59.2

Rollup

import svelte from 'rollup-plugin-svelte';
import css from 'rollup-plugin-css-only'
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import injectProcessEnv from 'rollup-plugin-inject-process-env';
import outputManifest from 'rollup-plugin-output-manifest';
import json from "@rollup/plugin-json";

export default [
  {
    input:'./client/admin.js',
    output: {
      sourcemap: process.env.NODE_ENV != "production",
      format: 'es',
      name: 'app',
      dir: 'storage/public/resources/site_tmp',
      manualChunks: undefined
    },
    plugins:[
       svelte({ emitCss:true }), 
       resolve({ browser: true, dedupe: ['svelte'] }), 
       commonjs(), 
       json(),
       css({ output: cssFilename }),
       injectProcessEnv({'NODE_ENV': process.env.NODE_ENV == "production" ? 'production' : 'development' }),
       outputManifest({isMerge:true})
    ]
  }
bundle 4.2 Size 3.1 Size Number of duplicates
admin.css 146kb 106kb 2
editor.css 812kb 147kb 18
site.css 743kb 101kb 15

The number of duplicate copies of the css seems related to the number of dynamic import() statements used within the specific bundle.

Hope that helps you reproduce and fix this issue.

@thgh
Copy link
Owner

thgh commented Jul 16, 2023

Do you mind checking out https://www.npmjs.com/package/rollup-plugin-import-css or https://www.npmjs.com/package/rollup-plugin-styles and see if those work for you?

I'm using higher level frameworks nowadays so won't fix bugs. Happy to merge a fix though!

@crisward
Copy link
Author

I may just keep using v3.1 for now. I'll check the above out if it becomes necessary.

If you're not planning on supporting this rollup plugin ( which I totally understand BTW ) , it may be worth letting the svelte team know as they still point to it as a way to compile your css. ( https://github.com/sveltejs/rollup-plugin-svelte#extracting-css ).

I'll leave it up to you if you'd like to close this, or leave it open so it doesn't get re-reported. Thanks again.

@rallets
Copy link

rallets commented Oct 6, 2023

@crisward FYI I just replaced rollup-plugin-css-only 4.3.0 with rollup-plugin-import-css 3.3.4 and everything worked as before.

@pioug
Copy link
Collaborator

pioug commented Nov 6, 2023

Should be fixed in v4.5.2. Feel free to reopen if it still reproducible.

@pioug pioug closed this as completed Nov 6, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants