fix: Cloudflare image provider only in production
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
import { version } from "./package.json";
|
import { version } from "./package.json";
|
||||||
|
|
||||||
const isDev = process.env.NODE_ENV !== "production";
|
|
||||||
|
|
||||||
const siteUrl = process.env.NUXT_SITE_URL;
|
const siteUrl = process.env.NUXT_SITE_URL;
|
||||||
if (!siteUrl) {
|
if (!siteUrl) {
|
||||||
throw new Error(`NUXT_SITE_URL is not defined. Make sure to set it in your build environment variables.`);
|
throw new Error(`NUXT_SITE_URL is not defined. Make sure to set it in your build environment variables.`);
|
||||||
@@ -13,6 +11,9 @@ if (!wpUrl) {
|
|||||||
}
|
}
|
||||||
const wpDomain = new URL(wpUrl).hostname;
|
const wpDomain = new URL(wpUrl).hostname;
|
||||||
|
|
||||||
|
const isDev = process.env.NODE_ENV !== "production";
|
||||||
|
const isWranglerDev = process.env.WRANGLER_ENV === "dev";
|
||||||
|
|
||||||
// https://nuxt.com/docs/api/configuration/nuxt-config
|
// https://nuxt.com/docs/api/configuration/nuxt-config
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
|
|
||||||
@@ -102,7 +103,7 @@ export default defineNuxtConfig({
|
|||||||
},
|
},
|
||||||
|
|
||||||
image: {
|
image: {
|
||||||
provider: isDev ? "ipx" : "cloudflare",
|
provider: isDev || isWranglerDev ? "none" : "cloudflare",
|
||||||
cloudflare: { baseURL: `${siteUrl}/` },
|
cloudflare: { baseURL: `${siteUrl}/` },
|
||||||
domains: [wpDomain],
|
domains: [wpDomain],
|
||||||
format: ["avif", "webp"],
|
format: ["avif", "webp"],
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"dev": "nuxt dev",
|
"dev": "nuxt dev",
|
||||||
"lint": "eslint --fix .",
|
"lint": "eslint --fix .",
|
||||||
"postinstall": "nuxt prepare",
|
"postinstall": "nuxt prepare",
|
||||||
"preview": "pnpm run build && wrangler dev --port 3000",
|
"preview": "WRANGLER_ENV=dev pnpm run build && wrangler dev --port 3000",
|
||||||
"release": "pnpm lint && changelogen --noAuthors --release --push",
|
"release": "pnpm lint && changelogen --noAuthors --release --push",
|
||||||
"typecheck": "nuxt typecheck"
|
"typecheck": "nuxt typecheck"
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user