Skip to content

Commit

Permalink
compile exifr source as well
Browse files Browse the repository at this point in the history
  • Loading branch information
johrstrom committed Jul 25, 2024
1 parent adf7a03 commit 96ea3ff
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions apps/dashboard/esbuild.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,24 @@ const prepPlugin = {
},
}


const preactSrcResolvePlugin = {
name: 'preactSrcResolve',
// don't package minified javascript
const minifiedSrcResolvePlugin = {
name: 'minifiedSrcResolvePlugin',
setup(build) {
// Redirect all paths starting with "images/" to "./public/images/"
build.onResolve({ filter: /preact/ }, args => {
const basePath = `${__dirname}/node_modules/preact`;
if (args.path == 'preact') {
return { path: `${basePath}/src/index.js` }
} else if(args.path == 'preact/hooks') {
return { path: `${basePath}/hooks/src/index.js` }
build.onResolve({ filter: /preact|exifr.*/ }, args => {

const preactBase = `${__dirname}/node_modules/preact`;
const lookup = {
'preact': `${preactBase}/src/index.js`,
'preact/hooks': `${preactBase}/hooks/src/index.js`,
'exifr/dist/mini.esm.mjs': `${__dirname}/node_modules/exifr/src/bundles/mini.mjs`,
}

for (const [key, value] of Object.entries(lookup)) {
if(args.path == key) {
return { path: value }
}
}
})
},
Expand All @@ -60,7 +67,7 @@ esbuild.build({
format: 'esm',
outdir: buildDir,
external: ['fs'],
plugins: [prepPlugin, preactSrcResolvePlugin],
plugins: [prepPlugin, minifiedSrcResolvePlugin],
minify: process.env.RAILS_ENV == 'production' ? true : false,
}).catch((e) => console.error(e.message));

0 comments on commit 96ea3ff

Please sign in to comment.