Skip to content

Commit

Permalink
chore: improve build setup
Browse files Browse the repository at this point in the history
  • Loading branch information
grikomsn committed Nov 24, 2023
1 parent 259ce27 commit fcd153a
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 70 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ NEXT_PUBLIC_API_URL=https://api.skip.money

# development API
# NEXT_PUBLIC_API_URL=https://solve-dev.skip.money

POLKACHU_USER=
POLKACHU_PASSWORD=
26 changes: 18 additions & 8 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@
"extends": [
"next/core-web-vitals",
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"plugin:@tanstack/eslint-plugin-query/recommended"
"plugin:@tanstack/eslint-plugin-query/recommended",
"plugin:prettier/recommended"
],
"plugins": ["@typescript-eslint", "prettier", "simple-import-sort"],
"parser": "@typescript-eslint/parser",
"plugins": ["simple-import-sort"],
"rules": {
"simple-import-sort/imports": "warn",
"@next/next/no-img-element": "off",
"simple-import-sort/exports": "warn",
"@next/next/no-img-element": "off"
}
"simple-import-sort/imports": "warn"
},
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"]
}
],
"root": true
}
59 changes: 18 additions & 41 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,47 +1,24 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

.DS_Store
.env*
!.env.example

src/chains/
tests/downloads/

# dependencies
/node_modules
/.pnp
.next
.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.sentryclirc
.turbo
.vercel

# typescript
.vscode
*.log
*.pem
*.tsbuildinfo
build
coverage
next-env.d.ts
/test-results/
/playwright-report/
/playwright/.cache/
node_modules
out
playwright-report
playwright/.cache/
src/chains/
test-results/
tests/downloads/

# Sentry Config File
.sentryclirc
!.env.example
2 changes: 2 additions & 0 deletions env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ declare namespace NodeJS {
interface ProcessEnv {
readonly APP_URL?: string;
readonly NEXT_PUBLIC_API_URL?: string;
readonly POLKACHU_USER?: string;
readonly POLKACHU_PASSWORD?: string;
}
}
3 changes: 3 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./tsconfig.json"
}
26 changes: 25 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/no-var-requires */
/// <reference path="./env.d.ts" />
/// <reference path="./vercel.d.ts" />

const APP_URL =
process.env.APP_URL ||
Expand Down Expand Up @@ -48,6 +49,10 @@ let nextConfig = {
"uuid",
]
: [],
webpack: (config, { dev, isServer }) => {
if (dev && isServer) checkEnv();
return config;
},
};

/** @see https://docs.sentry.io/platforms/javascript/guides/nextjs */
Expand Down Expand Up @@ -79,3 +84,22 @@ const sentryOptions = {
nextConfig = withSentryConfig(nextConfig, sentryWebpackConfig, sentryOptions);

module.exports = nextConfig;

function checkEnv() {
if (checkEnv.once) return;

const log = require("next/dist/build/output/log");

if (!process.env.NEXT_PUBLIC_API_URL) {
log.warn(
'env NEXT_PUBLIC_API_URL is not set, using SKIP_API_URL from "@skip-router/core"',
);
}
if (!process.env.POLKACHU_USER || !process.env.POLKACHU_PASSWORD) {
log.warn(
"env POLKACHU_USER or POLKACHU_PASSWORD is not set, /nodes/[chainID] will not work",
);
}

checkEnv.once = true;
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"dev": "next dev",
"lint": "next lint",
"postinstall": "git submodule init && git submodule update --remote && tsx ./src/scripts/codegen.ts",
"start": "next start",
"lint": "next lint",
"test": "jest",
"test:e2e": "playwright test --project=chromium"
},
Expand Down
37 changes: 19 additions & 18 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
{
"compilerOptions": {
"target": "es2020",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"forceConsistentCasingInFileNames": true,
"incremental": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"lib": ["dom", "dom.iterable", "esnext"],
"module": "esnext",
"moduleResolution": "node",
"noEmit": true,
"paths": {
"@/*": ["./src/*"]
},
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./src/*"]
}
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "es2020"
},
"exclude": ["node_modules"],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
"window.d.ts"
],
"exclude": ["node_modules"]
"env.d.ts",
"window.d.ts",
"**/*.ts",
"**/*.tsx"
]
}

0 comments on commit fcd153a

Please sign in to comment.