diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index ec70af8..3fd58ea 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -11,15 +11,14 @@ import Img, { FxReveal, FxParallax } from '$lib' import { version } from '$app/environment' import testSingle from './assets/640/01.jpg?w=80&h=80&format=jpg&as=run:0' import testFallback from './assets/640/01.jpg?h=80' +import testProfile from './assets/640/01.jpg?as=run2' const modules = import.meta.glob('./assets/640/*.jpg', { import: 'default', eager: true, query: { w: 640, h: 640, fit: 'cover', as: 'run' } }) - const esc = (i) => i - const images = Object.entries(modules).map((i) => i[1]) let selected = 0 @@ -94,11 +93,11 @@ export default defineConfig({

-
-
+
+
@@ -195,6 +194,9 @@ const images = Object.entries(modules).map((i) => i[1]) test
+ - - diff --git a/tests/test.js b/tests/test.js index 494bc7e..29d4c2d 100644 --- a/tests/test.js +++ b/tests/test.js @@ -34,6 +34,15 @@ test('run with param uses runDefaultDirectives', async ({ page }) => { expect(await page.locator('.test-run-param source').count()).toBe(3) }) +test('basic profile tests', async ({ page }) => { + await page.goto('/') + const img = async (attr) => await page.locator('.test-profile img').getAttribute(attr) + expect(await img('height')).toBe('16') + expect(await img('width')).toBe('32') + expect(await img('style')).toBeDefined() + expect(await page.locator('.test-profile source').count()).toBe(0) +}) + /* test('', async ({ page }) => { await page.goto('/') diff --git a/vite.config.js b/vite.config.js index 2e142c1..5571485 100644 --- a/vite.config.js +++ b/vite.config.js @@ -3,5 +3,12 @@ import { defineConfig } from 'vite' import { imagetools } from './src/lib/vite.js' export default defineConfig({ - plugins: [sveltekit(), imagetools()] + plugins: [ + sveltekit(), + imagetools({ + profiles: { + run2: new URLSearchParams('w=32&h=16&fit=cover&format=jpg') + } + }) + ] })