Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: Treat webmanifest as an entry module #2254

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/core/parcel-bundler/src/assets/HTMLAsset.js
Expand Up @@ -153,6 +153,20 @@ class HTMLAsset extends Asset {
}
}

if (
node.tag === 'link' &&
node.attrs.rel === 'manifest' &&
node.attrs.href
) {
node.attrs.href = this.getAttrDepHandler('href').call(
this,
node.attrs.href,
{entry: true}
);
this.isAstDirty = true;
return node;
}

for (let attr in node.attrs) {
let elements = ATTRS[attr];
// Check for virtual paths
Expand All @@ -163,6 +177,7 @@ class HTMLAsset extends Asset {
if (elements && elements.includes(node.tag)) {
let depHandler = this.getAttrDepHandler(attr);
let options = OPTIONS[node.tag];

AndreasPizsa marked this conversation as resolved.
Show resolved Hide resolved
node.attrs[attr] = depHandler.call(
this,
node.attrs[attr],
Expand Down
20 changes: 20 additions & 0 deletions packages/core/parcel-bundler/test/html.js
Expand Up @@ -591,6 +591,26 @@ describe('html', function() {
});
});

it("should treat webmanifest as an entry module so it doesn't get content hashed", async function() {
const b = await bundle(
path.join(__dirname, '/integration/html-manifest/index.html')
);

await assertBundleTree(b, {
name: 'index.html',
assets: ['index.html'],
childBundles: [
{
type: 'webmanifest',
assets: ['manifest.webmanifest']
}
]
});

const html = await fs.readFile(path.join(__dirname, '/dist/index.html'));
assert(html.includes('<link rel="manifest" href="/manifest.webmanifest">'));
});

it('should bundle svg files correctly', async function() {
let b = await bundle(
path.join(__dirname, '/integration/html-svg/index.html')
Expand Down
@@ -0,0 +1,8 @@
<!doctype html>
<html>
<head>
<link rel="manifest" href="manifest.webmanifest" />
</head>
<body>
</body>
</html>
@@ -0,0 +1,3 @@
{

}