Skip to content

Commit bd3cfea

Browse files
committed
Add default asset loaders to esbuild config
Common image and font file types now have default loaders (dataurl for images, file for fonts) so bundled client scripts can import assets without requiring a custom esbuild.settings.js. Closes #230
1 parent 5134ccc commit bd3cfea

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

lib/build-esbuild/index.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,22 @@ async function assembleBuildOpts (src, dest, siteData, opts, modeOpts = {}) {
204204
entryNames: watch ? '[dir]/[name]' : '[dir]/[name]-[hash]',
205205
chunkNames: 'chunks/[ext]/[name]-[hash]',
206206
jsx: 'automatic',
207-
jsxImportSource: 'preact'
207+
jsxImportSource: 'preact',
208+
loader: {
209+
'.png': 'dataurl',
210+
'.jpg': 'dataurl',
211+
'.jpeg': 'dataurl',
212+
'.gif': 'dataurl',
213+
'.svg': 'dataurl',
214+
'.webp': 'dataurl',
215+
'.avif': 'dataurl',
216+
'.ico': 'file',
217+
'.woff': 'file',
218+
'.woff2': 'file',
219+
'.ttf': 'file',
220+
'.eot': 'file',
221+
'.otf': 'file',
222+
}
208223
}
209224

210225
const esbuildSettingsExtends = siteData.esbuildSettings

0 commit comments

Comments
 (0)