Skip to content

Commit be57128

Browse files
author
Loïc Mangeonjean
committed
fix: fix resolving and respect external rollup option
1 parent aadcbea commit be57128

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/rollup-plugin-import-meta-assets/src/rollup-plugin-import-meta-assets.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,19 @@ ${` default: return new Promise(function(resolve, reject) {
161161
if (importMetaUrlType === 'static') {
162162
const absoluteScriptDir = path.dirname(id);
163163
const relativeAssetPath = getRelativeAssetPath(node);
164+
const resolved = await this.resolve(relativeAssetPath, id)
165+
if (resolved == null) {
166+
this.error(`Unable to resolve "${relativeAssetPath}" from "${id}"`)
167+
return
168+
}
169+
if (resolved.external) {
170+
return
171+
}
164172
const absoluteAssetPath = path.resolve(absoluteScriptDir, relativeAssetPath);
165173
const assetName = path.basename(absoluteAssetPath);
166174

167175
try {
168-
const assetContents = await fs.promises.readFile(absoluteAssetPath);
176+
const assetContents = await fs.promises.readFile(resolved.id);
169177
const transformedAssetContents =
170178
transform != null
171179
? await transform(assetContents, absoluteAssetPath)

0 commit comments

Comments
 (0)