Skip to content

Commit

Permalink
[#142] Fix cssAssetsFilterFunction breaks dynamic imports (#143)
Browse files Browse the repository at this point in the history
* fix: unused css assets should preserve vite imports

* 3.5.1
  • Loading branch information
marco-prontera authored Apr 27, 2024
1 parent 70b7939 commit 6c30640
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite-plugin-css-injected-by-js",
"version": "3.5.0",
"version": "3.5.1",
"description": "A Vite plugin that takes the CSS and adds it to the page through the JS. For those who want a single JS file.",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand Down
8 changes: 8 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ export default function cssInjectedByJsPlugin({
);
}
} else {
const allCssAssets = Object.keys(bundle).filter(
(i) =>
bundle[i].type == 'asset' &&
bundle[i].fileName.endsWith('.css')
);

unusedCssAssets = allCssAssets.filter(cssAsset => !cssAssets.includes(cssAsset));

await globalCssInjection(
bundle,
cssAssets,
Expand Down

0 comments on commit 6c30640

Please sign in to comment.