Skip to content

Commit

Permalink
setup: add package and env folr for different environment like dev, s…
Browse files Browse the repository at this point in the history
…taging and prod
  • Loading branch information
sahsisunny committed Nov 10, 2023
1 parent 1be31df commit deb037d
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NEXT_PUBLIC_API_BASE_URL=http://localhost:8000/v1
NEXT_PUBLIC_BASE_SHORT_URL=http://localhost:3000
2 changes: 2 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NEXT_PUBLIC_API_BASE_URL=https://staging-tinysite-api.realdevsquad.com/v1
NEXT_PUBLIC_BASE_SHORT_URL=https://staging-tinysite.realdevsquad.com
2 changes: 2 additions & 0 deletions .env.staging
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NEXT_PUBLIC_API_BASE_URL=https://staging-tinysite-api.realdevsquad.com/v1
NEXT_PUBLIC_BASE_SHORT_URL=https://staging-tinysite.realdevsquad.com
18 changes: 16 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};

module.exports = nextConfig;
const dotenv = require('dotenv');

const envFiles = {
development: '.env.development',
staging: '.env.staging',
production: '.env.production',
};

dotenv.config({ path: envFiles[process.env.NODE_ENV] || '.env.local' });

module.exports = {
reactStrictMode: true,
env: {
API_URL: process.env.API_URL,
},
};
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "tiny-site",
"version": "1.0.0",
"author": "Real Dev Squad",
"description": "This is a tiny site built with Next.js and Tailwind CSS",
"private": true,
"scripts": {
Expand Down Expand Up @@ -38,6 +39,7 @@
"@types/react-dom": "18.2.4",
"@typescript-eslint/eslint-plugin": "^5.59.7",
"@typescript-eslint/parser": "^5.59.7",
"dotenv": "^16.3.1",
"eslint": "8.41.0",
"eslint-config-next": "13.4.4",
"eslint-config-prettier": "^8.8.0",
Expand All @@ -56,5 +58,9 @@
"volta": {
"node": "18.14.0",
"yarn": "1.21.1"
},
"repository": {
"type": "git",
"url": "https://github.com/real-dev-squad/tiny-site-frontend.git"
}
}
10 changes: 6 additions & 4 deletions src/constants/url.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const TINY_API_URL = 'https://staging-tinysite-api.realdevsquad.com/v1';
export const TINY_API_GOOGLE_LOGIN = `${TINY_API_URL}/auth/google/login`;
export const TINY_API_LOGOUT = `${TINY_API_URL}/auth/logout`;
export const BASE_SHORT_URL = 'https://staging-tinysite.realdevsquad.com';
const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || 'https://staging-tinysite-api.realdevsquad.com/v1';
export const BASE_SHORT_URL = process.env.NEXT_PUBLIC_BASE_SHORT_URL || 'https://staging-tinysite.realdevsquad.com';

export const TINY_API_URL = API_BASE_URL;
export const TINY_API_GOOGLE_LOGIN = `${API_BASE_URL}/auth/google/login`;
export const TINY_API_LOGOUT = `${API_BASE_URL}/auth/logout`;
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1831,6 +1831,11 @@ domexception@^4.0.0:
dependencies:
webidl-conversions "^7.0.0"

dotenv@^16.3.1:
version "16.3.1"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.3.1.tgz#369034de7d7e5b120972693352a3bf112172cc3e"
integrity sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==

electron-to-chromium@^1.4.477:
version "1.4.511"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.511.tgz#8952ab359af63a32b990004bda8d0ef95df0950c"
Expand Down

0 comments on commit deb037d

Please sign in to comment.