-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix #6420 * add test * add test * fix an error that parsed path * fix path error when in Windows environment * fix a path error * update comment --------- Co-authored-by: wuls <linsheng.wu@beantechs.com>
- Loading branch information
1 parent
c1e8f42
commit a9c2299
Showing
7 changed files
with
101 additions
and
2 deletions.
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 | ||
--- | ||
|
||
Correctly generate directories for assets when users customise the output via rollup options. |
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,21 @@ | ||
import { expect } from 'chai'; | ||
import { loadFixture } from './test-utils.js'; | ||
|
||
describe('custom the assets name function', () => { | ||
/** @type {import('./test-utils').Fixture} */ | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/custom-assets-name/', | ||
output: 'server', | ||
}); | ||
await fixture.build(); | ||
}); | ||
|
||
it('It cant find this file cause the node throws an error if the users custom a path that includes the folder path', async () => { | ||
const csslength = await fixture.readFile('client/assets/css/a.css') | ||
/** @type {Set<string>} */ | ||
expect(!!csslength).to.equal(true); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
packages/astro/test/fixtures/custom-assets-name/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,34 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import path from "path"; | ||
|
||
// https://astro.build/config | ||
import node from "@astrojs/node"; | ||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
vite: { | ||
build: { | ||
cssCodeSplit: false, | ||
assetsInlineLimit: 0, | ||
rollupOptions: { | ||
output: { | ||
|
||
entryFileNames: 'assets/script/a.[hash].js', | ||
assetFileNames: (option) => { | ||
const { ext, dir, base } = path.parse(option.name); | ||
|
||
if (ext == ".css") return path.join(dir, "assets/css", 'a.css'); | ||
return "assets/img/[name].[ext]"; | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
build: { | ||
assets: 'assets' | ||
}, | ||
output: "server", | ||
adapter: node({ | ||
mode: "standalone" | ||
}) | ||
}); |
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/custom-assets-name", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*", | ||
"@astrojs/node": "workspace:*" | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
packages/astro/test/fixtures/custom-assets-name/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,18 @@ | ||
--- | ||
const title = 'My App'; | ||
--- | ||
|
||
<html> | ||
<head> | ||
<title>{title}</title> | ||
</head> | ||
<body> | ||
<h1>{title}</h1> | ||
</body> | ||
</html> | ||
|
||
<style> | ||
h1 { | ||
color: red; | ||
} | ||
</style> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.