Skip to content

Commit

Permalink
fix: NODE_ENV build issue
Browse files Browse the repository at this point in the history
  • Loading branch information
luwes committed Jun 3, 2024
1 parent 8da50b2 commit a7e5372
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/with-next-video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export function withNextVideo(nextConfig: any, videoConfig?: VideoConfig) {
const videoConfigComplete = Object.assign({}, videoConfigDefault, videoConfig);
const { path, folder, provider } = videoConfigComplete;

// env vars have to be set before the async function return!!
// env VARS have to be set before the async function return!!

// Don't use `process.env` here because Next.js replaces public env vars during build.
env['NEXT_PUBLIC_VIDEO_OPTS'] = JSON.stringify({ path, provider });
env['__NEXT_VIDEO_OPTS'] = JSON.stringify(videoConfigComplete);
env['NEXT_PUBLIC_VIDEO_OPTS'] = JSON.stringify({ path, folder, provider });

if (process.env.NODE_ENV === 'development') {
// We should probably switch to using `phase` here, just a bit concerned about backwards compatibility.
if (process.argv[2] === 'dev') {
// Don't use `process.env` here because Next.js replaces public env vars during build.
env['NEXT_PUBLIC_DEV_VIDEO_OPTS'] = JSON.stringify({ path, folder, provider });
}
Expand All @@ -28,7 +28,8 @@ export function withNextVideo(nextConfig: any, videoConfig?: VideoConfig) {
};
}

if (process.env.NODE_ENV === 'development') {
// We should probably switch to using `phase` here, just a bit concerned about backwards compatibility.
if (process.argv[2] === 'dev') {
const VIDEOS_PATH = join(process.cwd(), folder);
const TMP_PUBLIC_VIDEOS_PATH = join(process.cwd(), 'public', `_next-video`);

Expand Down

0 comments on commit a7e5372

Please sign in to comment.