Comments (9)
I've already deleted my prototype using dynamic imports. Tomorrow I'll try to put together repo with imports that don't resolve so we can eventually raise it as an issue at Vite.
from imagetools.
@JonasKruckenberg I had a look at the Vite source code and found that when using the as
parameter in the import options, this should theoretically be forwarded to the import statement, e.g.:
const images = import.meta.globEager("./*.jpg", {as: "w=250"});
However, this does not seem to work in practice, transforms are not applied.
from imagetools.
@palle-k I think you'd want to use query
for that: https://vitejs.dev/guide/features.html#custom-queries
from imagetools.
I'll try to see if this is possible once #17 is properly working, at least on next
.
I don't know how Vite behaves when glob importing so I can make no promises but I definitely doesn't seem complicated
from imagetools.
Alright, I've been digging around a bit in the vitejs source code and it seems that they are passing the full url to fast-glob, so importing your example ./images/*.jpg?width=200;400&format=webp;jpg&meta
Vite will try to match files in the asset directory with the pattern *.jpg?width=200;400&format=webp;jpg&meta
which will obviously not match anything.
So it seems like for now glob imports unfortunately don't work, no. :/
from imagetools.
Thanks for investigating the issue.
That sucks.. because in several occasions dynamic import(
${url}.jpg?webp)
could not be resolved which means I have to import every image manually meaning having for example 10 image import statements at the beginning of one file.
from imagetools.
Yeah that's very annoying yeah.
Can you share a situation in which the glob import doesn't resolve?
Maybe we can work around that somehow!
Maybe it'd be worth it to raise it as an issue over at the vite repo. I'll try to to this tomorrow if I have the time ππ»
from imagetools.
This I find is also a very good template: sveltejs/kit#241 (comment)
from imagetools.
I've added import.meta.glob
to the docs and example to show how to use it
from imagetools.
Related Issues (20)
- Query strings don't work in dynamic imports with template literals containing variables HOT 8
- Upgrading to Vite 4.4.0 broke vite-imagetools HOT 5
- imagetools-core 4.0.4 `resolveConfigs` behavior change, `format` directive no longer working
- Build and build -w output differs HOT 6
- as=source and as=srcset both outputting srcset with all the same width params HOT 3
- manifest.json is generated incorrectly HOT 2
- Upgrading Vite-imagetools 5.0.8 throws an error from 4.x version HOT 2
- generateImageID causes tests to fail on CI HOT 3
- Vite example has a typo HOT 1
- Renaming picture fallback to img is not reflected in the document HOT 1
- Waste less effort transforming images
- Dependency on sharp not declared correctly for yarnβs PnP loader HOT 9
- Vite plugin crash HOT 2
- Loading attribute HOT 1
- v6 broken due to missing sharp 0.33 binariers HOT 3
- Some images get rotated for some reason HOT 14
- crop from / "gravity" HOT 1
- Error: Unable to parse color from string: ##ffaa22
- Pre-transform error: Failed to parse source for import analysis because the content contains invalid JS syntax
- How to receive access to original image in `extendOutputFormats` after v7.0.0? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imagetools.