fix adblock issue (#2875)
This commit is contained in:
parent
d763ec183e
commit
5571227718
5 changed files with 17 additions and 12 deletions
5
.changeset/strong-bears-knock.md
Normal file
5
.changeset/strong-bears-knock.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Generalize output assets to avoid adblocker false positives
|
|
@ -109,9 +109,9 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
|
||||||
input: Array.from(input),
|
input: Array.from(input),
|
||||||
output: {
|
output: {
|
||||||
format: 'esm',
|
format: 'esm',
|
||||||
entryFileNames: '[name].[hash].mjs',
|
entryFileNames: 'entry.[hash].mjs',
|
||||||
chunkFileNames: 'chunks/[name].[hash].mjs',
|
chunkFileNames: 'chunks/chunk.[hash].mjs',
|
||||||
assetFileNames: 'assets/[name].[hash][extname]',
|
assetFileNames: 'assets/asset.[hash][extname]',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// must match an esbuild target
|
// must match an esbuild target
|
||||||
|
@ -162,9 +162,9 @@ async function clientBuild(opts: StaticBuildOptions, internals: BuildInternals,
|
||||||
input: Array.from(input),
|
input: Array.from(input),
|
||||||
output: {
|
output: {
|
||||||
format: 'esm',
|
format: 'esm',
|
||||||
entryFileNames: '[name].[hash].js',
|
entryFileNames: 'entry.[hash].js',
|
||||||
chunkFileNames: 'chunks/[name].[hash].js',
|
chunkFileNames: 'chunks/chunk.[hash].js',
|
||||||
assetFileNames: 'assets/[name].[hash][extname]',
|
assetFileNames: 'assets/asset.[hash][extname]',
|
||||||
},
|
},
|
||||||
preserveEntrySignatures: 'exports-only',
|
preserveEntrySignatures: 'exports-only',
|
||||||
},
|
},
|
||||||
|
|
|
@ -22,6 +22,6 @@ describe('Client only components', () => {
|
||||||
const script = $script.html();
|
const script = $script.html();
|
||||||
|
|
||||||
// test 2: svelte renderer is on the page
|
// test 2: svelte renderer is on the page
|
||||||
expect(/import\(".\/PersistentCounter.*/g.test(script)).to.be.ok;
|
expect(/import\(".\/entry.*/g.test(script)).to.be.ok;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,9 +5,9 @@ import { loadFixture } from './test-utils.js';
|
||||||
// note: the hashes should be deterministic, but updating the file contents will change hashes
|
// note: the hashes should be deterministic, but updating the file contents will change hashes
|
||||||
// be careful not to test that the HTML simply contains CSS, because it always will! filename and quanity matter here (bundling).
|
// be careful not to test that the HTML simply contains CSS, because it always will! filename and quanity matter here (bundling).
|
||||||
const EXPECTED_CSS = {
|
const EXPECTED_CSS = {
|
||||||
'/index.html': ['/assets/index'], // don’t match hashes, which change based on content
|
'/index.html': ['/assets/'], // don’t match hashes, which change based on content
|
||||||
'/one/index.html': ['/assets/one'],
|
'/one/index.html': ['/assets/'],
|
||||||
'/two/index.html': ['/assets/two'],
|
'/two/index.html': ['/assets/'],
|
||||||
};
|
};
|
||||||
const UNEXPECTED_CSS = ['/src/components/nav.css', '../css/typography.css', '../css/colors.css', '../css/page-index.css', '../css/page-one.css', '../css/page-two.css'];
|
const UNEXPECTED_CSS = ['/src/components/nav.css', '../css/typography.css', '../css/colors.css', '../css/page-index.css', '../css/page-one.css', '../css/page-two.css'];
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ describe('CSS Bundling', function () {
|
||||||
// test 1: assert new bundled CSS is present
|
// test 1: assert new bundled CSS is present
|
||||||
for (const href of css) {
|
for (const href of css) {
|
||||||
const link = $(`link[rel="stylesheet"][href^="${href}"]`);
|
const link = $(`link[rel="stylesheet"][href^="${href}"]`);
|
||||||
expect(link).to.have.lengthOf(1);
|
expect(link.length).to.be.greaterThanOrEqual(1);
|
||||||
const outHref = link.attr('href');
|
const outHref = link.attr('href');
|
||||||
builtCSS.add(outHref.startsWith('../') ? outHref.substr(2) : outHref);
|
builtCSS.add(outHref.startsWith('../') ? outHref.substr(2) : outHref);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,6 @@ describe('Dynamic components', () => {
|
||||||
// test 2: correct script is being loaded.
|
// test 2: correct script is being loaded.
|
||||||
// because of bundling, we don't have access to the source import,
|
// because of bundling, we don't have access to the source import,
|
||||||
// only the bundled import.
|
// only the bundled import.
|
||||||
expect($('script').html()).to.include(`import setup from '../only`);
|
expect($('script').html()).to.include(`import setup from '../entry`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue