-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow specifying entryFileNames for client JS (#3676)
* Allow specifying entryFileNames for client JS * Adds a changeset
- Loading branch information
Showing
8 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Allow specifying entryFileNames for client JS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { expect } from 'chai'; | ||
import * as cheerio from 'cheerio'; | ||
import { loadFixture } from './test-utils.js'; | ||
|
||
describe('vite.build.rollupOptions.entryFileNames', () => { | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/entry-file-names', | ||
}); | ||
await fixture.build(); | ||
}); | ||
|
||
it('Renders correctly', async () => { | ||
const html = await fixture.readFile('/index.html'); | ||
const $ = cheerio.load(html); | ||
expect($('#hello')).to.have.a.lengthOf(1); | ||
}); | ||
|
||
it('Outputs a client module that was specified by the config', async () => { | ||
const js = await fixture.readFile('/assets/js/Hello.js'); | ||
expect(js).to.be.a('string'); | ||
expect(js.length).to.be.greaterThan(0); | ||
}) | ||
}); |
16 changes: 16 additions & 0 deletions
16
packages/astro/test/fixtures/entry-file-names/astro.config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import preact from '@astrojs/preact'; | ||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
integrations: [preact()], | ||
vite: { | ||
build: { | ||
rollupOptions: { | ||
output: { | ||
entryFileNames: `assets/js/[name].js`, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "@test/entry-file-names", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"@astrojs/preact": "workspace:", | ||
"astro": "workspace:*" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
packages/astro/test/fixtures/entry-file-names/src/components/Hello.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
export default function() { | ||
return ( | ||
<div id="hello">Hello world</div> | ||
) | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/astro/test/fixtures/entry-file-names/src/pages/index.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
import Hello from '../components/Hello.jsx'; | ||
--- | ||
|
||
<html> | ||
<head><title>Test</title></head> | ||
<body> | ||
<Hello client:load /> | ||
</body> | ||
</html> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.