Skip to content

Commit

Permalink
Fix cdn related logics
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallku committed Feb 6, 2024
1 parent e79f7b5 commit 62c16a4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions apps/blog/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
const path = require("path");

const analyzing = process.env.ANALYZE === "true";
const isProd = process.env.NODE_ENV === "production";

/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
transpilePackages: ["@marshallku/ui"],
output: "standalone",
assetPrefix: isProd ? "https://cdn-t.marshallku.com/files" : undefined,
assetPrefix: process.env.NEXT_PUBLIC_FILE_CDN_URL,
experimental: {
outputFileTracingRoot: path.join(__dirname, "../../"),
},
Expand Down
4 changes: 2 additions & 2 deletions apps/blog/src/components/Image/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ function Image({ src, alt, width, height, forceSize, ...rest }: ImageProps) {
return (
<img
src={`${process.env.NEXT_PUBLIC_CDN_URL}${src}${
forceSize && process.env.NODE_ENV !== "development" ? `=w${forceSize}` : ""
forceSize && process.env.NEXT_PUBLIC_CDN_URL !== "" ? `=w${forceSize}` : ""
}`}
srcSet={
width && height && process.env.NODE_ENV !== "development"
width && height && process.env.NEXT_PUBLIC_CDN_URL !== ""
? IMAGE_SIZE.filter((size) => size < Number(width))
.map((size) => `${process.env.NEXT_PUBLIC_CDN_URL}${src}=w${size} ${size}w`)
.join(", ")
Expand Down
2 changes: 1 addition & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dev": {
"cache": false,
"persistent": true,
"env": ["NODE_ENV", "NEXT_PUBLIC_BLOG_ORIGIN", "NEXT_PUBLIC_CDN_URL"]
"env": ["NODE_ENV", "NEXT_PUBLIC_BLOG_ORIGIN", "NEXT_PUBLIC_CDN_URL", "NEXT_PUBLIC_FILE_CDN_URL"]
},
"clean": {
"cache": false
Expand Down

0 comments on commit 62c16a4

Please sign in to comment.