Skip to content

Commit

Permalink
Add rotation bug workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
happycollision committed Jul 12, 2024
1 parent ec67f67 commit e57e69d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion scripts/enhancedImg/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from "node:path"
import { imagetools } from "vite-imagetools"
import { imagetools, rotate } from "vite-imagetools"
import { image } from "./preprocessor.js"

/**
Expand Down Expand Up @@ -63,6 +63,20 @@ const fallback = {
async function imagetools_plugin() {
/** @type {Partial<import('vite-imagetools').VitePluginOptions>} */
const imagetools_opts = {
extendTransforms: () => {
return [
function noRotate(config, ctx) {
const rotateNone = rotate({ rotate: "0" }, ctx)
if (!rotateNone) {
return
}

return function customTransform(image) {
return rotateNone(image)
}
},
]
},
defaultDirectives: async ({ pathname, searchParams: qs }, metadata) => {
if (!qs.has("enhanced")) return new URLSearchParams()

Expand All @@ -83,6 +97,7 @@ async function imagetools_plugin() {
})
},
namedExports: false,
removeMetadata: false,
}

// TODO: should we make formats or sizes configurable besides just letting people override defaultDirectives?
Expand Down

0 comments on commit e57e69d

Please sign in to comment.