config: remove ~/assets alias (#8113)
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> Co-authored-by: Mia Kanashi <chad@redpilled.dev>
This commit is contained in:
parent
4967c69221
commit
2484dc4080
13 changed files with 68 additions and 24 deletions
13
.changeset/clever-bats-breathe.md
Normal file
13
.changeset/clever-bats-breathe.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
'astro': major
|
||||
---
|
||||
|
||||
This import alias is no longer included by default with astro:assets. If you were using this alias with experimental assets, you must convert them to relative file paths, or create your own [import aliases](https://docs.astro.build/en/guides/aliases/).
|
||||
|
||||
```diff
|
||||
---
|
||||
// src/pages/posts/post-1.astro
|
||||
- import rocket from '~/assets/rocket.png'
|
||||
+ import rocket from '../../assets/rocket.png';
|
||||
---
|
||||
```
|
|
@ -90,7 +90,7 @@ export type LocalImageProps<T> = ImageSharedProps<T> & {
|
|||
*
|
||||
* **Example**:
|
||||
* ```js
|
||||
* import myImage from "~/assets/my_image.png";
|
||||
* import myImage from "../assets/my_image.png";
|
||||
* ```
|
||||
* And then refer to the image, like so:
|
||||
* ```astro
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import MagicString from 'magic-string';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import type * as vite from 'vite';
|
||||
import { normalizePath } from 'vite';
|
||||
import type { AstroPluginOptions, ImageTransform } from '../@types/astro';
|
||||
|
@ -31,18 +30,6 @@ export default function assets({
|
|||
// Expose the components and different utilities from `astro:assets` and handle serving images from `/_image` in dev
|
||||
{
|
||||
name: 'astro:assets',
|
||||
config() {
|
||||
return {
|
||||
resolve: {
|
||||
alias: [
|
||||
{
|
||||
find: /^~\/assets\/(.+)$/,
|
||||
replacement: fileURLToPath(new URL('./assets/$1', settings.config.srcDir)),
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
},
|
||||
async resolveId(id) {
|
||||
if (id === VIRTUAL_SERVICE_ID) {
|
||||
return await this.resolve(settings.config.image.service.entrypoint);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"alt": "Futuristic landscape with chrome buildings and blue skies",
|
||||
"src": "~/assets/the-future.jpg"
|
||||
"src": "../../assets/the-future.jpg"
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
title: One
|
||||
image: ~/assets/penguin2.jpg
|
||||
image: ../../assets/penguin2.jpg
|
||||
cover:
|
||||
image: ../../assets/penguin1.jpg
|
||||
---
|
||||
|
|
9
packages/astro/test/fixtures/core-image-base/tsconfig.json
vendored
Normal file
9
packages/astro/test/fixtures/core-image-base/tsconfig.json
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"extends": "astro/tsconfigs/base",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"~/assets/*": ["src/assets/*"]
|
||||
},
|
||||
}
|
||||
}
|
9
packages/astro/test/fixtures/core-image-ssg/tsconfig.json
vendored
Normal file
9
packages/astro/test/fixtures/core-image-ssg/tsconfig.json
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"extends": "astro/tsconfigs/base",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"~/assets/*": ["src/assets/*"]
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
---
|
||||
title: One
|
||||
image: ~/assets/penguin2.jpg
|
||||
image: ../../assets/penguin2.jpg
|
||||
cover:
|
||||
image: ../../assets/penguin1.jpg
|
||||
arrayOfImages:
|
||||
- ~/assets/penguin2.jpg
|
||||
- ~/assets/penguin1.jpg
|
||||
- ../../assets/penguin2.jpg
|
||||
- ../../assets/penguin1.jpg
|
||||
refinedImage: ../../assets/penguin1.jpg
|
||||
---
|
||||
|
||||
|
|
9
packages/astro/test/fixtures/core-image/tsconfig.json
vendored
Normal file
9
packages/astro/test/fixtures/core-image/tsconfig.json
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"extends": "astro/tsconfigs/base",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"~/assets/*": ["src/assets/*"]
|
||||
},
|
||||
}
|
||||
}
|
|
@ -23,11 +23,6 @@
|
|||
"esModuleInterop": true,
|
||||
// Skip typechecking libraries and .d.ts files
|
||||
"skipLibCheck": true,
|
||||
// Add alias for assets folder for easy reference to assets
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"~/assets/*": ["src/assets/*"]
|
||||
},
|
||||
// Allow JavaScript files to be imported
|
||||
"allowJs": true
|
||||
}
|
||||
|
|
9
packages/integrations/markdoc/test/fixtures/image-assets/tsconfig.json
vendored
Normal file
9
packages/integrations/markdoc/test/fixtures/image-assets/tsconfig.json
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"extends": "astro/tsconfigs/base",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"~/assets/*": ["src/assets/*"]
|
||||
},
|
||||
}
|
||||
}
|
9
packages/integrations/mdx/test/fixtures/mdx-images/tsconfig.json
vendored
Normal file
9
packages/integrations/mdx/test/fixtures/mdx-images/tsconfig.json
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"extends": "astro/tsconfigs/base",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"~/assets/*": ["src/assets/*"]
|
||||
},
|
||||
}
|
||||
}
|
|
@ -18252,21 +18252,25 @@ packages:
|
|||
file:packages/astro/test/fixtures/css-assets/packages/font-awesome:
|
||||
resolution: {directory: packages/astro/test/fixtures/css-assets/packages/font-awesome, type: directory}
|
||||
name: '@test/astro-font-awesome-package'
|
||||
version: 0.0.1
|
||||
dev: false
|
||||
|
||||
file:packages/astro/test/fixtures/multiple-renderers/renderers/one:
|
||||
resolution: {directory: packages/astro/test/fixtures/multiple-renderers/renderers/one, type: directory}
|
||||
name: '@test/astro-renderer-one'
|
||||
version: 1.0.0
|
||||
dev: false
|
||||
|
||||
file:packages/astro/test/fixtures/multiple-renderers/renderers/two:
|
||||
resolution: {directory: packages/astro/test/fixtures/multiple-renderers/renderers/two, type: directory}
|
||||
name: '@test/astro-renderer-two'
|
||||
version: 1.0.0
|
||||
dev: false
|
||||
|
||||
file:packages/astro/test/fixtures/solid-component/deps/solid-jsx-component:
|
||||
resolution: {directory: packages/astro/test/fixtures/solid-component/deps/solid-jsx-component, type: directory}
|
||||
name: '@test/solid-jsx-component'
|
||||
version: 0.0.0
|
||||
dependencies:
|
||||
solid-js: 1.7.6
|
||||
dev: false
|
||||
|
|
Loading…
Reference in a new issue