From 24f3212a21902a4b94d031e32c0b05aadf038ee9 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Wed, 14 Sep 2022 11:37:26 -0400 Subject: [PATCH] Tailwind thing --- packages/astro/test/astro-scripts.test.js | 17 +++++++++ .../fixtures/astro-scripts/astro.config.mjs | 36 +++++++++++++++++++ .../test/fixtures/astro-scripts/package.json | 3 +- .../src/pages/inline-in-page.astro | 12 +++++++ pnpm-lock.yaml | 2 ++ 5 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 packages/astro/test/fixtures/astro-scripts/astro.config.mjs create mode 100644 packages/astro/test/fixtures/astro-scripts/src/pages/inline-in-page.astro diff --git a/packages/astro/test/astro-scripts.test.js b/packages/astro/test/astro-scripts.test.js index 1229de5f5..55097b7a5 100644 --- a/packages/astro/test/astro-scripts.test.js +++ b/packages/astro/test/astro-scripts.test.js @@ -150,5 +150,22 @@ describe('Scripts (hoisted and not)', () => { }); expect(found).to.equal(1); }); + + it.only('Using injectScript does not interfere', async () => { + let res = await fixture.fetch('/inline-in-page'); + let html = await res.text(); + let $ = cheerio.load(html); + //console.log(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); + }); }); }); diff --git a/packages/astro/test/fixtures/astro-scripts/astro.config.mjs b/packages/astro/test/fixtures/astro-scripts/astro.config.mjs new file mode 100644 index 000000000..440661908 --- /dev/null +++ b/packages/astro/test/fixtures/astro-scripts/astro.config.mjs @@ -0,0 +1,36 @@ +import { defineConfig } from 'astro/config'; +import tailwind from '@astrojs/tailwind'; + +export default defineConfig({ + integrations: [ + tailwind() + // { + // name: '@test-inject-script', + // hooks: { + // 'astro:config:setup'({ injectScript, updateConfig }) { + // injectScript('page-ssr', `import 'virtual:test';`); + // updateConfig({ + // vite: { + // plugins: [ + // { + // name: '@test-inject-script', + // resolveId(id) { + // if(id === 'virtual:test') { + // return id; + // } + // }, + // load(id) { + // if(id === 'virtual:test') { + // console.log('loading it'); + // return 'export default void 0;' + // } + // } + // } + // ] + // } + // }) + // } + // } + // } + ] +}) diff --git a/packages/astro/test/fixtures/astro-scripts/package.json b/packages/astro/test/fixtures/astro-scripts/package.json index 6d6da3520..5ec16b38e 100644 --- a/packages/astro/test/fixtures/astro-scripts/package.json +++ b/packages/astro/test/fixtures/astro-scripts/package.json @@ -3,6 +3,7 @@ "version": "0.0.0", "private": true, "dependencies": { - "astro": "workspace:*" + "astro": "workspace:*", + "@astrojs/tailwind": "workspace:*" } } diff --git a/packages/astro/test/fixtures/astro-scripts/src/pages/inline-in-page.astro b/packages/astro/test/fixtures/astro-scripts/src/pages/inline-in-page.astro new file mode 100644 index 000000000..ce9e2733e --- /dev/null +++ b/packages/astro/test/fixtures/astro-scripts/src/pages/inline-in-page.astro @@ -0,0 +1,12 @@ + + + + Testing + + +

Testing

+ + + diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c8412144d..00289ea36 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1356,8 +1356,10 @@ importers: packages/astro/test/fixtures/astro-scripts: specifiers: + '@astrojs/tailwind': workspace:* astro: workspace:* dependencies: + '@astrojs/tailwind': link:../../../../integrations/tailwind astro: link:../../.. packages/astro/test/fixtures/astro-sitemap-rss: