rollup-plugin-visualizer
rollup-plugin-visualizer copied to clipboard
CSS files reported as zero-length
See https://github.com/mrginglymus/rpv-css/blob/main/dist/stats.json - the file is present, but reported as zero length.
As a workaround currently I'm applying the following patch:
diff --git a/dist/plugin/index.js b/dist/plugin/index.js
index cbac456309032373a79a3209a5f80fa720157afa..18591f0cde08c48eaafcc7df58fab5459fad1d1d 100644
--- a/dist/plugin/index.js
+++ b/dist/plugin/index.js
@@ -93,7 +93,7 @@ const visualizer = (opts = {}) => {
else {
const modules = await Promise.all(Object.entries(bundle.modules)
.filter(([id]) => filter(bundleId, id))
- .map(([id, { renderedLength, code }]) => getModuleLengths({ id, renderedLength, code }), false));
+ .map(([id, { renderedLength, code, originalLength }]) => getModuleLengths({ id, renderedLength: id.endsWith('.css') ? originalLength : renderedLength, code }, id.endsWith('.css')), false));
tree = (0, data_1.buildTree)(bundleId, modules, mapper);
}
if (tree.children.length === 0) {
however, as code is null this doesn't really help with gzip calculations.
Hey, thanks for bringing this. Can you elaborate on your setup? Specifically plugins you uses and css dialects if any? Would be nice you make short example that i can use for debug (to understand if plugin put css as asset for example, assets do not have code)
Hi @btd - the linked stats file is in a minimal repro - https://github.com/mrginglymus/rpv-css/blob/main/vite.config.js - pure js, css, the only plugin is the visualiser, and I've disabled module preload only to ensure only js I've written is emitted.
Core issue there is that for non js files rollup do not include neither code, nor renderedLength. Also module from bundle do not indicate if entry is asset. I do not want really hack this around, need first understand why it is so.