Skip to content

Commit c30651e

Browse files
committed
fix(rollup-plugin-html): properly exclude assets referenced in css files too
1 parent 50c410e commit c30651e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/rollup-plugin-html/src/output/emitAssets.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { transform } from 'lightningcss';
44
import fs from 'fs';
55

66
import { InputAsset, InputData } from '../input/InputData';
7+
import { createAssetPicomatchMatcher } from '../assets/utils.js';
78
import { RollupPluginHTMLOptions, TransformAssetFunction } from '../RollupPluginHTMLOptions';
89

910
export interface EmittedAssets {
@@ -81,6 +82,7 @@ export async function emitAssets(
8182

8283
let ref: string;
8384
let basename = path.basename(asset.filePath);
85+
const isExternal = createAssetPicomatchMatcher(options.externalAssets);
8486
const emittedExternalAssets = new Map();
8587
if (asset.hashed) {
8688
if (basename.endsWith('.css') && options.bundleAssetsFromCss) {
@@ -95,7 +97,7 @@ export async function emitAssets(
9597
// https://www.w3.org/TR/html4/types.html#:~:text=ID%20and%20NAME%20tokens%20must,tokens%20defined%20by%20other%20attributes.
9698
const [filePath, idRef] = url.url.split('#');
9799

98-
if (shouldHandleAsset(filePath)) {
100+
if (shouldHandleAsset(filePath) && !isExternal(filePath)) {
99101
// Read the asset file, get the asset from the source location on the FS using asset.filePath
100102
const assetLocation = path.resolve(path.dirname(asset.filePath), filePath);
101103
const assetContent = fs.readFileSync(assetLocation);

0 commit comments

Comments
 (0)