Skip to content

Commit

Permalink
Compatiblity between hoisted scripts and tailwind integration (#4755)
Browse files Browse the repository at this point in the history
* Compatiblity between hoisted scripts and tailwind integration

* Adds a changeset
  • Loading branch information
matthewp authored Sep 14, 2022
1 parent 1bedb94 commit f1efd88
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 22 deletions.
5 changes: 5 additions & 0 deletions .changeset/spotty-ways-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Upgrade to Vite 3.1
4 changes: 2 additions & 2 deletions packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"recast": "^0.20.5",
"rehype": "^12.0.1",
"resolve": "^1.22.0",
"rollup": "~2.77.0",
"rollup": "~2.78.0",
"semver": "^7.3.7",
"shiki": "^0.11.1",
"sirv": "^2.0.2",
Expand All @@ -149,7 +149,7 @@
"tsconfig-resolver": "^3.0.1",
"unist-util-visit": "^4.1.0",
"vfile": "^5.3.2",
"vite": "3.0.9",
"vite": "3.1.0",
"yargs-parser": "^21.0.1",
"zod": "^3.17.3"
},
Expand Down
19 changes: 18 additions & 1 deletion packages/astro/test/astro-scripts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ describe('Scripts (hoisted and not)', () => {
let html = await fixture.readFile('/with-styles/index.html');
let $ = cheerio.load(html);

expect($('link[rel=stylesheet]')).to.have.a.lengthOf(1);
// Imported styles + tailwind
expect($('link[rel=stylesheet]')).to.have.a.lengthOf(2);
});
});

Expand Down Expand Up @@ -150,5 +151,21 @@ describe('Scripts (hoisted and not)', () => {
});
expect(found).to.equal(1);
});

it('Using injectScript does not interfere', async () => {
let res = await fixture.fetch('/inline-in-page');
let html = await res.text();
let $ = cheerio.load(html);
let found = 0;
let moduleScripts = $('[type=module]');
moduleScripts.each((i, el) => {
if (
$(el).attr('src').includes('?astro&type=script&index=0&lang.ts')
) {
found++;
}
});
expect(found).to.equal(1);
});
});
});
8 changes: 8 additions & 0 deletions packages/astro/test/fixtures/astro-scripts/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from 'astro/config';
import tailwind from '@astrojs/tailwind';

export default defineConfig({
integrations: [
tailwind()
]
})
3 changes: 2 additions & 1 deletion packages/astro/test/fixtures/astro-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"astro": "workspace:*"
"astro": "workspace:*",
"@astrojs/tailwind": "workspace:*"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

<html>
<head>
<title>Testing</title>
</head>
<body>
<h1>Testing</h1>
<script>
console.log('hi');
</script>
</body>
</html>
30 changes: 12 additions & 18 deletions pnpm-lock.yaml

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

0 comments on commit f1efd88

Please sign in to comment.