@akanjs/config 0.0.40 → 0.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +132 -3
- package/index.js +358 -67
- package/package.json +5 -2
- package/src/akanConfig.d.ts +7 -140
- package/src/akanConfig.ts +141 -0
- package/src/baseConfigEnv.d.ts +2 -3
- package/src/baseConfigEnv.ts +21 -0
- package/src/capacitor.base.config.ts +39 -0
- package/src/nextConfig.d.ts +7 -10
- package/src/nextConfig.ts +195 -0
- package/src/postcss.config.base.js +20 -19
- package/src/styles.css +165 -5
- package/src/akanConfig.js +0 -141
- package/src/baseConfigEnv.js +0 -42
- package/src/capacitor.base.config.d.ts +0 -5
- package/src/capacitor.base.config.js +0 -74
- package/src/nextConfig.js +0 -277
package/src/akanConfig.d.ts
CHANGED
|
@@ -1,140 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
declare const
|
|
5
|
-
declare const
|
|
6
|
-
declare const
|
|
7
|
-
declare const
|
|
8
|
-
declare const getNextConfig: (configImp: AppConfig, appData: any) => NextConfig | (() => Promise<NextConfig> | NextConfig);
|
|
9
|
-
|
|
10
|
-
interface RunnerProps {
|
|
11
|
-
appName: string;
|
|
12
|
-
repoName: string;
|
|
13
|
-
serveDomain: string;
|
|
14
|
-
env: "testing" | "debug" | "develop" | "main";
|
|
15
|
-
command?: string;
|
|
16
|
-
}
|
|
17
|
-
type Arch = "amd64" | "arm64";
|
|
18
|
-
type ExplicitDependencies = string[] | {
|
|
19
|
-
[key in Arch]: string[];
|
|
20
|
-
};
|
|
21
|
-
interface AppConfigResult {
|
|
22
|
-
rootLib?: string;
|
|
23
|
-
libs: string[];
|
|
24
|
-
backend: {
|
|
25
|
-
dockerfile: string;
|
|
26
|
-
explicitDependencies: ExplicitDependencies;
|
|
27
|
-
};
|
|
28
|
-
frontend: {
|
|
29
|
-
dockerfile: string;
|
|
30
|
-
nextConfig: NextConfig | (() => Promise<NextConfig> | NextConfig);
|
|
31
|
-
routes?: {
|
|
32
|
-
basePath?: string;
|
|
33
|
-
domains: {
|
|
34
|
-
main?: string[];
|
|
35
|
-
develop?: string[];
|
|
36
|
-
debug?: string[];
|
|
37
|
-
};
|
|
38
|
-
}[];
|
|
39
|
-
explicitDependencies: ExplicitDependencies;
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
interface LibConfigResult {
|
|
43
|
-
rootLib?: string;
|
|
44
|
-
libs: string[];
|
|
45
|
-
backend: {
|
|
46
|
-
explicitDependencies: ExplicitDependencies;
|
|
47
|
-
};
|
|
48
|
-
frontend: {
|
|
49
|
-
explicitDependencies: ExplicitDependencies;
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
type DeepPartial<T> = {
|
|
53
|
-
[P in keyof T]?: T[P] extends any[] ? T[P] : T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
54
|
-
};
|
|
55
|
-
type AppConfig = DeepPartial<AppConfigResult> | ((props: RunnerProps) => DeepPartial<AppConfigResult>);
|
|
56
|
-
type LibConfig = DeepPartial<LibConfigResult> | ((props: RunnerProps) => DeepPartial<LibConfigResult>);
|
|
57
|
-
interface AkanConfigFile {
|
|
58
|
-
default: NextConfig;
|
|
59
|
-
}
|
|
60
|
-
interface FileConventionScanResult {
|
|
61
|
-
constants: {
|
|
62
|
-
databases: string[];
|
|
63
|
-
scalars: string[];
|
|
64
|
-
};
|
|
65
|
-
dictionary: {
|
|
66
|
-
databases: string[];
|
|
67
|
-
services: string[];
|
|
68
|
-
scalars: string[];
|
|
69
|
-
};
|
|
70
|
-
documents: {
|
|
71
|
-
databases: string[];
|
|
72
|
-
scalars: string[];
|
|
73
|
-
};
|
|
74
|
-
services: {
|
|
75
|
-
databases: string[];
|
|
76
|
-
services: string[];
|
|
77
|
-
scalars: string[];
|
|
78
|
-
};
|
|
79
|
-
signal: {
|
|
80
|
-
databases: string[];
|
|
81
|
-
services: string[];
|
|
82
|
-
scalars: string[];
|
|
83
|
-
};
|
|
84
|
-
store: {
|
|
85
|
-
databases: string[];
|
|
86
|
-
services: string[];
|
|
87
|
-
scalars: string[];
|
|
88
|
-
};
|
|
89
|
-
components: {
|
|
90
|
-
databases: string[];
|
|
91
|
-
services: string[];
|
|
92
|
-
scalars: string[];
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
declare const getDefaultFileScan: () => FileConventionScanResult;
|
|
96
|
-
interface AppScanResult {
|
|
97
|
-
name: string;
|
|
98
|
-
type: "app" | "lib";
|
|
99
|
-
akanConfig: AppConfigResult;
|
|
100
|
-
files: FileConventionScanResult;
|
|
101
|
-
libDeps: string[];
|
|
102
|
-
pkgDeps: string[];
|
|
103
|
-
dependencies: string[];
|
|
104
|
-
libs: {
|
|
105
|
-
[key: string]: LibScanResult;
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
interface LibScanResult {
|
|
109
|
-
name: string;
|
|
110
|
-
type: "app" | "lib";
|
|
111
|
-
akanConfig: LibConfigResult;
|
|
112
|
-
files: FileConventionScanResult;
|
|
113
|
-
libDeps: string[];
|
|
114
|
-
pkgDeps: string[];
|
|
115
|
-
dependencies: string[];
|
|
116
|
-
libs: {
|
|
117
|
-
[key: string]: LibScanResult;
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
interface PkgScanResult {
|
|
121
|
-
name: string;
|
|
122
|
-
pkgDeps: string[];
|
|
123
|
-
dependencies: string[];
|
|
124
|
-
}
|
|
125
|
-
interface WorkspaceScanResult {
|
|
126
|
-
appNames: string[];
|
|
127
|
-
libNames: string[];
|
|
128
|
-
pkgNames: string[];
|
|
129
|
-
apps: {
|
|
130
|
-
[key: string]: AppScanResult;
|
|
131
|
-
};
|
|
132
|
-
libs: {
|
|
133
|
-
[key: string]: LibScanResult;
|
|
134
|
-
};
|
|
135
|
-
pkgs: {
|
|
136
|
-
[key: string]: PkgScanResult;
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export { type Arch as A, type DeepPartial as D, type ExplicitDependencies as E, type FileConventionScanResult as F, type LibConfigResult as L, type PkgScanResult as P, type RunnerProps as R, type WorkspaceScanResult as W, type AppConfigResult as a, type AppConfig as b, type LibConfig as c, type AkanConfigFile as d, type AppScanResult as e, type LibScanResult as f, getDefaultFileScan as g, getAppConfig, getLibConfig, getNextConfig, makeAppConfig, makeLibConfig };
|
|
1
|
+
import type { AppConfig, AppConfigResult, DeepPartial, LibConfigResult, RunnerProps } from "@akanjs/config";
|
|
2
|
+
import type { NextConfig } from "next";
|
|
3
|
+
export declare const makeAppConfig: (config: DeepPartial<AppConfigResult>, props?: Partial<RunnerProps>) => AppConfigResult;
|
|
4
|
+
export declare const getAppConfig: (appRoot: string, props: RunnerProps) => Promise<AppConfigResult>;
|
|
5
|
+
export declare const makeLibConfig: (config: DeepPartial<LibConfigResult>, props?: Partial<RunnerProps>) => LibConfigResult;
|
|
6
|
+
export declare const getLibConfig: (libRoot: string, props: RunnerProps) => Promise<LibConfigResult>;
|
|
7
|
+
export declare const getNextConfig: (configImp: AppConfig, appData: any) => NextConfig | (() => Promise<NextConfig> | NextConfig);
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AppConfig,
|
|
3
|
+
AppConfigResult,
|
|
4
|
+
AppScanResult,
|
|
5
|
+
DeepPartial,
|
|
6
|
+
LibConfig,
|
|
7
|
+
LibConfigResult,
|
|
8
|
+
RunnerProps,
|
|
9
|
+
} from "@akanjs/config";
|
|
10
|
+
import fs from "fs";
|
|
11
|
+
import type { NextConfig } from "next";
|
|
12
|
+
import path from "path";
|
|
13
|
+
|
|
14
|
+
import { getBaseConfigEnv } from "./baseConfigEnv";
|
|
15
|
+
import { withBase } from "./nextConfig";
|
|
16
|
+
|
|
17
|
+
export const makeAppConfig = (
|
|
18
|
+
config: DeepPartial<AppConfigResult>,
|
|
19
|
+
props: Partial<RunnerProps> = {}
|
|
20
|
+
): AppConfigResult => {
|
|
21
|
+
const baseConfigEnv = getBaseConfigEnv(props.appName);
|
|
22
|
+
const {
|
|
23
|
+
appName = baseConfigEnv.appName,
|
|
24
|
+
repoName = baseConfigEnv.repoName,
|
|
25
|
+
serveDomain = baseConfigEnv.serveDomain,
|
|
26
|
+
env = baseConfigEnv.env,
|
|
27
|
+
command = "build",
|
|
28
|
+
} = props;
|
|
29
|
+
return {
|
|
30
|
+
rootLib: config.rootLib,
|
|
31
|
+
libs: config.libs ?? [],
|
|
32
|
+
backend: {
|
|
33
|
+
dockerfile:
|
|
34
|
+
config.backend?.dockerfile ??
|
|
35
|
+
`FROM node:22-slim
|
|
36
|
+
RUN ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
|
|
37
|
+
RUN apt-get update && apt-get upgrade -y
|
|
38
|
+
RUN apt-get install -y ca-certificates fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils udev
|
|
39
|
+
ARG TARGETARCH
|
|
40
|
+
RUN if [ "$TARGETARCH" = "amd64" ]; then \
|
|
41
|
+
wget https://fastdl.mongodb.org/tools/db/mongodb-database-tools-debian92-x86_64-100.3.1.deb && \
|
|
42
|
+
apt-get install -y ./mongodb-database-tools-*.deb && \
|
|
43
|
+
rm -f mongodb-database-tools-*.deb; \
|
|
44
|
+
fi
|
|
45
|
+
RUN apt-get install -y git redis build-essential python3
|
|
46
|
+
RUN rm -rf /var/lib/apt/lists/*
|
|
47
|
+
RUN mkdir -p /workspace
|
|
48
|
+
WORKDIR /workspace
|
|
49
|
+
COPY ./package.json ./package.json
|
|
50
|
+
RUN npx pnpm i --prod
|
|
51
|
+
COPY . .
|
|
52
|
+
ENV PORT 8080
|
|
53
|
+
ENV NODE_OPTIONS=--max_old_space_size=8192
|
|
54
|
+
ENV NEXT_PUBLIC_REPO_NAME=${repoName}
|
|
55
|
+
ENV NEXT_PUBLIC_SERVE_DOMAIN=${serveDomain}
|
|
56
|
+
ENV NEXT_PUBLIC_APP_NAME=${appName}
|
|
57
|
+
ENV NEXT_PUBLIC_ENV=${env}
|
|
58
|
+
ENV NEXT_PUBLIC_OPERATION_MODE=cloud
|
|
59
|
+
CMD ["node", "main.js"]`,
|
|
60
|
+
explicitDependencies: (config.backend?.explicitDependencies as string[] | undefined) ?? ([] as string[]),
|
|
61
|
+
},
|
|
62
|
+
frontend: {
|
|
63
|
+
dockerfile:
|
|
64
|
+
config.frontend?.dockerfile ??
|
|
65
|
+
`FROM node:22-alpine
|
|
66
|
+
RUN ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
|
|
67
|
+
RUN apk --no-cache add git
|
|
68
|
+
RUN mkdir -p /workspace
|
|
69
|
+
WORKDIR /workspace
|
|
70
|
+
COPY ./package.json ./package.json
|
|
71
|
+
RUN npx pnpm i --prod
|
|
72
|
+
COPY . .
|
|
73
|
+
ENV PORT 4200
|
|
74
|
+
ENV NODE_OPTIONS=--max_old_space_size=8192
|
|
75
|
+
ENV NEXT_PUBLIC_REPO_NAME=${repoName}
|
|
76
|
+
ENV NEXT_PUBLIC_SERVE_DOMAIN=${serveDomain}
|
|
77
|
+
ENV NEXT_PUBLIC_APP_NAME=${appName}
|
|
78
|
+
ENV NEXT_PUBLIC_ENV=${env}
|
|
79
|
+
ENV NEXT_PUBLIC_OPERATION_MODE=cloud
|
|
80
|
+
CMD ["npm", "start"]`,
|
|
81
|
+
nextConfig: withBase(
|
|
82
|
+
appName,
|
|
83
|
+
config.frontend?.nextConfig
|
|
84
|
+
? typeof config.frontend.nextConfig === "function"
|
|
85
|
+
? (config.frontend as { nextConfig: () => NextConfig }).nextConfig()
|
|
86
|
+
: config.frontend.nextConfig
|
|
87
|
+
: {},
|
|
88
|
+
config.libs ?? [],
|
|
89
|
+
config.frontend?.routes
|
|
90
|
+
),
|
|
91
|
+
explicitDependencies: (config.frontend?.explicitDependencies as string[] | undefined) ?? ([] as string[]),
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const getAppConfig = async (appRoot: string, props: RunnerProps): Promise<AppConfigResult> => {
|
|
97
|
+
const akanConfigPath = path.join(appRoot, "akan.config.ts");
|
|
98
|
+
if (!fs.existsSync(akanConfigPath)) throw new Error(`application akan.config.ts is not found ${appRoot}`);
|
|
99
|
+
const configImp = ((await import(`${appRoot}/akan.config.ts`)) as { default: AppConfig }).default;
|
|
100
|
+
const config = typeof configImp === "function" ? configImp(props) : configImp;
|
|
101
|
+
return makeAppConfig(config, props);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export const makeLibConfig = (
|
|
105
|
+
config: DeepPartial<LibConfigResult>,
|
|
106
|
+
props: Partial<RunnerProps> = {}
|
|
107
|
+
): LibConfigResult => {
|
|
108
|
+
return {
|
|
109
|
+
rootLib: config.rootLib,
|
|
110
|
+
libs: config.libs ?? [],
|
|
111
|
+
backend: {
|
|
112
|
+
explicitDependencies: (config.backend?.explicitDependencies as string[] | undefined) ?? ([] as string[]),
|
|
113
|
+
},
|
|
114
|
+
frontend: {
|
|
115
|
+
explicitDependencies: (config.frontend?.explicitDependencies as string[] | undefined) ?? ([] as string[]),
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export const getLibConfig = async (libRoot: string, props: RunnerProps): Promise<LibConfigResult> => {
|
|
121
|
+
const akanConfigPath = path.join(libRoot, "akan.config.ts");
|
|
122
|
+
if (!fs.existsSync(akanConfigPath)) throw new Error(`library akan.config.ts is not found ${libRoot}`);
|
|
123
|
+
const configImp = ((await import(`${libRoot}/akan.config.ts`)) as { default: LibConfig }).default;
|
|
124
|
+
const config = typeof configImp === "function" ? configImp(props) : configImp;
|
|
125
|
+
return makeLibConfig(config, props);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export const getNextConfig = (configImp: AppConfig, appData: any) => {
|
|
129
|
+
const appInfo = appData as AppScanResult;
|
|
130
|
+
const baseConfigEnv = getBaseConfigEnv(appInfo.name);
|
|
131
|
+
const props: RunnerProps = {
|
|
132
|
+
appName: baseConfigEnv.appName,
|
|
133
|
+
repoName: baseConfigEnv.repoName,
|
|
134
|
+
serveDomain: baseConfigEnv.serveDomain,
|
|
135
|
+
env: baseConfigEnv.env,
|
|
136
|
+
command: "build",
|
|
137
|
+
};
|
|
138
|
+
const config = typeof configImp === "function" ? configImp(props) : configImp;
|
|
139
|
+
const akanConfig = makeAppConfig(config, props);
|
|
140
|
+
return akanConfig.frontend.nextConfig;
|
|
141
|
+
};
|
package/src/baseConfigEnv.d.ts
CHANGED
|
@@ -4,6 +4,5 @@ interface BaseConfigEnv {
|
|
|
4
4
|
serveDomain: string;
|
|
5
5
|
env: "testing" | "debug" | "develop" | "main";
|
|
6
6
|
}
|
|
7
|
-
declare const getBaseConfigEnv: (appName?: string | undefined) => BaseConfigEnv;
|
|
8
|
-
|
|
9
|
-
export { getBaseConfigEnv };
|
|
7
|
+
export declare const getBaseConfigEnv: (appName?: string | undefined) => BaseConfigEnv;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface BaseConfigEnv {
|
|
2
|
+
appName: string;
|
|
3
|
+
repoName: string;
|
|
4
|
+
serveDomain: string;
|
|
5
|
+
env: "testing" | "debug" | "develop" | "main";
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const getBaseConfigEnv = (appName = process.env.NEXT_PUBLIC_APP_NAME): BaseConfigEnv => {
|
|
9
|
+
if (!appName) throw new Error("NEXT_PUBLIC_APP_NAME is not set");
|
|
10
|
+
|
|
11
|
+
const repoName = process.env.NEXT_PUBLIC_REPO_NAME;
|
|
12
|
+
if (!repoName) throw new Error("NEXT_PUBLIC_REPO_NAME is not set");
|
|
13
|
+
|
|
14
|
+
const serveDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN;
|
|
15
|
+
if (!serveDomain) throw new Error("NEXT_PUBLIC_SERVE_DOMAIN is not set");
|
|
16
|
+
|
|
17
|
+
const env = (process.env.NEXT_PUBLIC_ENV ?? "debug") as "testing" | "debug" | "develop" | "main" | undefined;
|
|
18
|
+
if (!env) throw new Error("NEXT_PUBLIC_ENV is not set");
|
|
19
|
+
|
|
20
|
+
return { appName, repoName, serveDomain, env };
|
|
21
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { CapacitorConfig } from "@capacitor/cli";
|
|
2
|
+
import os from "os";
|
|
3
|
+
|
|
4
|
+
const getLocalIP = () => {
|
|
5
|
+
const interfaces = os.networkInterfaces();
|
|
6
|
+
for (const interfaceName in interfaces) {
|
|
7
|
+
const iface = interfaces[interfaceName];
|
|
8
|
+
if (!iface) continue;
|
|
9
|
+
for (const alias of iface) {
|
|
10
|
+
if (alias.family === "IPv4" && !alias.internal) return alias.address;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return "127.0.0.1"; // fallback to localhost if no suitable IP found
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const withBase = (applyConfig: (config: CapacitorConfig) => CapacitorConfig) => {
|
|
17
|
+
const projectName = process.env.NEXT_PUBLIC_APP_NAME;
|
|
18
|
+
if (!projectName) throw new Error("projectName is not defined, please run with nx command");
|
|
19
|
+
const ip = getLocalIP();
|
|
20
|
+
const baseConfig: CapacitorConfig = {
|
|
21
|
+
appId: `com.${projectName}`,
|
|
22
|
+
appName: projectName,
|
|
23
|
+
webDir: `../../dist/apps/${projectName}/csr/`,
|
|
24
|
+
// bundledWebRuntime: false, !not used
|
|
25
|
+
server:
|
|
26
|
+
process.env.APP_OPERATION_MODE !== "release"
|
|
27
|
+
? {
|
|
28
|
+
androidScheme: "http",
|
|
29
|
+
url: `http://${ip}:4201`,
|
|
30
|
+
cleartext: true,
|
|
31
|
+
allowNavigation: [`http://${ip}:8080/*`],
|
|
32
|
+
}
|
|
33
|
+
: undefined,
|
|
34
|
+
plugins: {
|
|
35
|
+
CapacitorCookies: { enabled: true },
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
return applyConfig(baseConfig);
|
|
39
|
+
};
|
package/src/nextConfig.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { NextConfig } from
|
|
2
|
-
|
|
3
|
-
type
|
|
4
|
-
type
|
|
5
|
-
|
|
6
|
-
declare const composePlugins: (...plugins: (NextPlugin | NextPluginThatReturnsConfigFn)[]) => ((baseConfig: NextConfig) => NextConfigFn);
|
|
1
|
+
import type { NextConfig } from "next";
|
|
2
|
+
export type NextConfigFn = (phase: string, context?: any) => Promise<NextConfig> | NextConfig;
|
|
3
|
+
export type NextPlugin = (config: NextConfig) => NextConfig;
|
|
4
|
+
export type NextPluginThatReturnsConfigFn = (config: NextConfig) => NextConfigFn;
|
|
5
|
+
export declare const composePlugins: (...plugins: (NextPlugin | NextPluginThatReturnsConfigFn)[]) => ((baseConfig: NextConfig) => NextConfigFn);
|
|
7
6
|
/**
|
|
8
7
|
* @type { (config: import('@nx/next/plugins/with-nx').WithNxOptions) = import('@nx/next/plugins/with-nx').WithNxOptions }
|
|
9
8
|
**/
|
|
10
|
-
declare const withBase: (appName: string, config: NextConfig, libs: string[], routes?: {
|
|
9
|
+
export declare const withBase: (appName: string, config: NextConfig, libs: string[], routes?: {
|
|
11
10
|
basePath?: string;
|
|
12
11
|
domains: {
|
|
13
12
|
main?: string[];
|
|
@@ -15,6 +14,4 @@ declare const withBase: (appName: string, config: NextConfig, libs: string[], ro
|
|
|
15
14
|
debug?: string[];
|
|
16
15
|
};
|
|
17
16
|
}[]) => NextConfigFn;
|
|
18
|
-
declare const defaultNextConfigFile = "import \"tsconfig-paths/register\";\n\nimport { getNextConfig } from \"@akanjs/config\";\n\nimport appInfo from \"./akan.app.json\";\nimport config from \"./akan.config\";\n\nexport default getNextConfig(config, appInfo);\n";
|
|
19
|
-
|
|
20
|
-
export { type NextConfigFn, type NextPlugin, type NextPluginThatReturnsConfigFn, composePlugins, defaultNextConfigFile, withBase };
|
|
17
|
+
export declare const defaultNextConfigFile = "import \"tsconfig-paths/register\";\n\nimport { getNextConfig } from \"@akanjs/config\";\n\nimport appInfo from \"./akan.app.json\";\nimport config from \"./akan.config\";\n\nexport default getNextConfig(config, appInfo);\n";
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
2
|
+
import withAnalyze from "@next/bundle-analyzer";
|
|
3
|
+
import type { NextConfig } from "next";
|
|
4
|
+
import pwa from "next-pwa";
|
|
5
|
+
import runtimeCaching from "next-pwa/cache";
|
|
6
|
+
import path from "path";
|
|
7
|
+
|
|
8
|
+
export type NextConfigFn = (phase: string, context?: any) => Promise<NextConfig> | NextConfig;
|
|
9
|
+
|
|
10
|
+
export type NextPlugin = (config: NextConfig) => NextConfig;
|
|
11
|
+
|
|
12
|
+
export type NextPluginThatReturnsConfigFn = (config: NextConfig) => NextConfigFn;
|
|
13
|
+
|
|
14
|
+
export const composePlugins = (
|
|
15
|
+
...plugins: (NextPlugin | NextPluginThatReturnsConfigFn)[]
|
|
16
|
+
): ((baseConfig: NextConfig) => NextConfigFn) => {
|
|
17
|
+
return function (baseConfig: NextConfig) {
|
|
18
|
+
return async function combined(phase: string, context: any): Promise<NextConfig> {
|
|
19
|
+
let config = baseConfig;
|
|
20
|
+
for (const plugin of plugins) {
|
|
21
|
+
const fn = plugin;
|
|
22
|
+
const configOrFn = fn(config);
|
|
23
|
+
if (typeof configOrFn === "function") config = await configOrFn(phase, context);
|
|
24
|
+
else config = configOrFn;
|
|
25
|
+
}
|
|
26
|
+
return config;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const commandType = process.env.AKAN_COMMAND_TYPE?.includes("serve")
|
|
32
|
+
? "serve"
|
|
33
|
+
: process.env.AKAN_COMMAND_TYPE?.includes("build")
|
|
34
|
+
? "build"
|
|
35
|
+
: "deploy";
|
|
36
|
+
const withPWA = pwa({
|
|
37
|
+
dest: "public",
|
|
38
|
+
register: true,
|
|
39
|
+
skipWaiting: true,
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
41
|
+
runtimeCaching,
|
|
42
|
+
disable: commandType === "serve",
|
|
43
|
+
});
|
|
44
|
+
const devDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? "akanjs.com";
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @type { (config: import('@nx/next/plugins/with-nx').WithNxOptions) = import('@nx/next/plugins/with-nx').WithNxOptions }
|
|
48
|
+
**/
|
|
49
|
+
export const withBase = (
|
|
50
|
+
appName: string,
|
|
51
|
+
config: NextConfig,
|
|
52
|
+
libs: string[],
|
|
53
|
+
routes: { basePath?: string; domains: { main?: string[]; develop?: string[]; debug?: string[] } }[] = []
|
|
54
|
+
) => {
|
|
55
|
+
return composePlugins(
|
|
56
|
+
withAnalyze({ enabled: process.env.ANALYZE === "true" }) as unknown as NextPlugin,
|
|
57
|
+
...(commandType !== "serve" || process.env.USE_PWA === "true" ? [withPWA as unknown as NextPlugin] : [])
|
|
58
|
+
)({
|
|
59
|
+
...config,
|
|
60
|
+
eslint: { ...config.eslint, ignoreDuringBuilds: true },
|
|
61
|
+
env: {
|
|
62
|
+
...config.env,
|
|
63
|
+
basePaths: routes.map(({ basePath }) => basePath).join(","),
|
|
64
|
+
},
|
|
65
|
+
transpilePackages: [
|
|
66
|
+
"swiper",
|
|
67
|
+
"ssr-window",
|
|
68
|
+
"dom7",
|
|
69
|
+
...libs.map((lib) => `@${lib}`),
|
|
70
|
+
"@akanjs/base",
|
|
71
|
+
"@akanjs/common",
|
|
72
|
+
"@akanjs/next",
|
|
73
|
+
"@akanjs/ui",
|
|
74
|
+
"@akanjs/client",
|
|
75
|
+
"@akanjs/server",
|
|
76
|
+
"@akanjs/service",
|
|
77
|
+
"@akanjs/signal",
|
|
78
|
+
"@akanjs/store",
|
|
79
|
+
"@akanjs/dictionary",
|
|
80
|
+
"@akanjs/constant",
|
|
81
|
+
"@akanjs/config",
|
|
82
|
+
"@akanjs/document",
|
|
83
|
+
],
|
|
84
|
+
reactStrictMode: commandType === "serve" ? false : true,
|
|
85
|
+
experimental: {
|
|
86
|
+
...(config.experimental ?? {}),
|
|
87
|
+
optimizePackageImports: [
|
|
88
|
+
...[appName, ...libs].map((lib) => [`@${lib}/ui`, `@${lib}/next`, `@${lib}/common`, `@${lib}/client`]).flat(),
|
|
89
|
+
"@contract",
|
|
90
|
+
"@akanjs/next",
|
|
91
|
+
"@akanjs/common",
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
// modularizeImports: {
|
|
95
|
+
// "react-icons/?(((\\w*)?/?)*)": {
|
|
96
|
+
// transform: "@react-icons/all-files/{{ matches.[1] }}/{{member}}",
|
|
97
|
+
// skipDefaultConversion: true,
|
|
98
|
+
// },
|
|
99
|
+
// lodash: { transform: "lodash/{{member}}", preventFullImport: true },
|
|
100
|
+
// ...Object.fromEntries(
|
|
101
|
+
// [appName, ...libs].reduce(
|
|
102
|
+
// (acc, lib) => [
|
|
103
|
+
// ...acc,
|
|
104
|
+
// [`@${lib}/ui`, { transform: `@${lib}/ui/{{member}}`, skipDefaultConversion: true }],
|
|
105
|
+
// [`@${lib}/next`, { transform: `@${lib}/next/{{member}}`, skipDefaultConversion: true }],
|
|
106
|
+
// [`@${lib}/common`, { transform: `@${lib}/common/{{member}}`, skipDefaultConversion: true }],
|
|
107
|
+
// [`@${lib}/client`, { transform: `@${lib}/lib/{{ camelCase member }}`, skipDefaultConversion: true }],
|
|
108
|
+
// ],
|
|
109
|
+
// [
|
|
110
|
+
// ["@contract", { transform: `@contract/src/{{member}}`, skipDefaultConversion: true }],
|
|
111
|
+
// [`@akanjs/next`, { transform: `@akanjs/next/src/{{member}}`, skipDefaultConversion: true }],
|
|
112
|
+
// [`@akanjs/common`, { transform: `@akanjs/common/src/{{member}}`, skipDefaultConversion: true }],
|
|
113
|
+
// ]
|
|
114
|
+
// )
|
|
115
|
+
// ),
|
|
116
|
+
// ...(config.modularizeImports ?? {}),
|
|
117
|
+
// },
|
|
118
|
+
images: {
|
|
119
|
+
formats: ["image/avif", "image/webp"],
|
|
120
|
+
...(config.images ?? {}),
|
|
121
|
+
remotePatterns: [
|
|
122
|
+
...(config.images?.remotePatterns ?? []),
|
|
123
|
+
...routes
|
|
124
|
+
.map(({ domains }) => [
|
|
125
|
+
...(domains.main?.map((domain) => ({ protocol: "https", hostname: `**.${domain}` })) ?? []),
|
|
126
|
+
...(domains.develop?.map((domain) => ({ protocol: "https", hostname: `**.${domain}` })) ?? []),
|
|
127
|
+
...(domains.debug?.map((domain) => ({ protocol: "https", hostname: `**.${domain}` })) ?? []),
|
|
128
|
+
])
|
|
129
|
+
.flat(),
|
|
130
|
+
{ protocol: "https", hostname: `**.${devDomain}` },
|
|
131
|
+
],
|
|
132
|
+
},
|
|
133
|
+
webpack: (config: NextConfig) => {
|
|
134
|
+
// react-pdf error fix
|
|
135
|
+
config.resolve.alias.canvas = false;
|
|
136
|
+
config.resolve.alias.encoding = false;
|
|
137
|
+
if (process.env.USE_AKANJS_PKGS === "true")
|
|
138
|
+
config.resolve.alias["@akanjs/config"] = path.resolve(__dirname, "../../../../pkgs/@akanjs/config");
|
|
139
|
+
return config;
|
|
140
|
+
},
|
|
141
|
+
redirects() {
|
|
142
|
+
return routes
|
|
143
|
+
.map(({ basePath, domains }) => [
|
|
144
|
+
{ basePath, domain: `${basePath}-debug.${devDomain}` },
|
|
145
|
+
{ basePath, domain: `${basePath}-develop.${devDomain}` },
|
|
146
|
+
{ basePath, domain: `${basePath}-main.${devDomain}` },
|
|
147
|
+
...(domains.main?.map((domain) => ({ basePath, domain })) ?? []),
|
|
148
|
+
...(domains.develop?.map((domain) => ({ basePath, domain })) ?? []),
|
|
149
|
+
...(domains.debug?.map((domain) => ({ basePath, domain })) ?? []),
|
|
150
|
+
])
|
|
151
|
+
.flat()
|
|
152
|
+
.map(({ basePath, domain }) => ({
|
|
153
|
+
source: `/:locale/${basePath}/:path*`,
|
|
154
|
+
has: [{ type: "host", value: domain }],
|
|
155
|
+
permanent: true,
|
|
156
|
+
destination: "/:locale/:path*",
|
|
157
|
+
}));
|
|
158
|
+
},
|
|
159
|
+
rewrites() {
|
|
160
|
+
return routes
|
|
161
|
+
.map(({ basePath, domains }) => [
|
|
162
|
+
{ basePath, domain: `${basePath}-debug.${devDomain}` },
|
|
163
|
+
{ basePath, domain: `${basePath}-develop.${devDomain}` },
|
|
164
|
+
{ basePath, domain: `${basePath}-main.${devDomain}` },
|
|
165
|
+
...(domains.main?.map((domain) => ({ basePath, domain })) ?? []),
|
|
166
|
+
...(domains.develop?.map((domain) => ({ basePath, domain })) ?? []),
|
|
167
|
+
...(domains.debug?.map((domain) => ({ basePath, domain })) ?? []),
|
|
168
|
+
])
|
|
169
|
+
.flat()
|
|
170
|
+
.map(({ basePath, domain }) => [
|
|
171
|
+
{
|
|
172
|
+
source: "/:locale",
|
|
173
|
+
has: [{ type: "host", value: domain }],
|
|
174
|
+
destination: `/:locale/${basePath}`,
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
source: `/:locale/:path((?!${basePath}$)(?!admin(?:/|$)).*)`,
|
|
178
|
+
has: [{ type: "host", value: domain }],
|
|
179
|
+
destination: `/:locale/${basePath}/:path*`,
|
|
180
|
+
},
|
|
181
|
+
])
|
|
182
|
+
.flat();
|
|
183
|
+
},
|
|
184
|
+
} as unknown as NextConfig);
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export const defaultNextConfigFile = `import "tsconfig-paths/register";
|
|
188
|
+
|
|
189
|
+
import { getNextConfig } from "@akanjs/config";
|
|
190
|
+
|
|
191
|
+
import appInfo from "./akan.app.json";
|
|
192
|
+
import config from "./akan.config";
|
|
193
|
+
|
|
194
|
+
export default getNextConfig(config, appInfo);
|
|
195
|
+
`;
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
const path = require("path");
|
|
4
|
-
|
|
2
|
+
|
|
3
|
+
const withBase = (config = {}) => ({
|
|
5
4
|
...config,
|
|
6
5
|
plugins: {
|
|
7
|
-
...process.env.USE_AKANJS_PKGS === "true"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
...(process.env.USE_AKANJS_PKGS === "true"
|
|
7
|
+
? {
|
|
8
|
+
"postcss-import": {
|
|
9
|
+
resolve(id) {
|
|
10
|
+
if (id.startsWith("@akanjs/config/src"))
|
|
11
|
+
return path.resolve(__dirname, id.replace("@akanjs/config/src/", ""));
|
|
12
|
+
else return id;
|
|
13
|
+
},
|
|
14
|
+
},
|
|
12
15
|
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
module.exports = {
|
|
22
|
-
withBase
|
|
23
|
-
};
|
|
16
|
+
: {}),
|
|
17
|
+
"@tailwindcss/postcss": process.env.AKAN_WORKSPACE_ROOT
|
|
18
|
+
? { base: path.join(process.env.AKAN_WORKSPACE_ROOT, "./") }
|
|
19
|
+
: {},
|
|
20
|
+
...(config.plugins ?? {}),
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
module.exports = { withBase };
|