Meant to be used with [vanilla-extract](https://github.com/vanilla-extract-css/vanilla-extract) and its Vite plugin. See [this](https://github.com/vanilla-extract-css/vanilla-extract/issues/665).
npm install esbuild-vanilla-image-loaderMeant to be used with vanilla-extract and its Vite plugin. See this.
``bash`
pnpm add esbuild-vanilla-image-loader -D
`ts
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin'
import { ImageLoader } from 'esbuild-vanilla-image-loader'
export default defineConfig({
plugins: [
vanillaExtractPlugin({
esbuildOptions: {
plugins: [ImageLoader()],
}
}),
],
})
`
`ts
// src/style/App.css.ts
import { style } from '@vanilla-extract/css'
import Pic from './pic.png'
export const root = style({
backgroundImage: url(${Pic}),`
height: 200,
width: 200
})
`ts``
ImageLoader({
filter: /\.(gif|jpe?g|tiff?|png|webp|bmp)$/,
dataUrl: false, // Read file as dataurl
})
MIT