@akanjs/config 0.0.33 → 0.0.35

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/src/next.base.js DELETED
@@ -1,156 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var next_base_exports = {};
29
- __export(next_base_exports, {
30
- withBase: () => withBase
31
- });
32
- module.exports = __toCommonJS(next_base_exports);
33
- var import_bundle_analyzer = __toESM(require("@next/bundle-analyzer"));
34
- var import_next = require("@nx/next");
35
- var import_next_pwa = __toESM(require("next-pwa"));
36
- var import_cache = __toESM(require("next-pwa/cache"));
37
- const commandType = process.env.NX_TASK_TARGET_TARGET?.includes("serve") ? "serve" : process.env.NX_TASK_TARGET_TARGET?.includes("build") ? "build" : "deploy";
38
- const withPWA = (0, import_next_pwa.default)({
39
- dest: "public",
40
- register: true,
41
- skipWaiting: true,
42
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
43
- runtimeCaching: import_cache.default
44
- // disable: commandType === "serve",
45
- });
46
- const devDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? "akanjs.com";
47
- const libs = ["game", "mint", "platform", "social", "shared", "util"];
48
- const withBase = (appName, config, routes = []) => {
49
- return (0, import_next.composePlugins)(
50
- import_next.withNx,
51
- (0, import_bundle_analyzer.default)({ enabled: process.env.ANALYZE === "true" }),
52
- ...commandType !== "serve" || process.env.USE_PWA === "true" ? [withPWA] : []
53
- )({
54
- ...config,
55
- env: {
56
- ...config.env,
57
- basePaths: routes.map(({ basePath }) => basePath).join(",")
58
- },
59
- transpilePackages: ["swiper", "ssr-window", "dom7"],
60
- reactStrictMode: commandType === "serve" ? false : true,
61
- nx: { svgr: false },
62
- // experimental: {
63
- // ...(config.experimental ?? {}),
64
- // optimizePackageImports: [
65
- // "react-icons",
66
- // "lodash",
67
- // ...[appName, ...libs].map((lib) => [`@${lib}/ui`, `@${lib}/next`, `@${lib}/common`, `@${lib}/client`]).flat(),
68
- // "@contract",
69
- // "@akanjs/next",
70
- // "@akanjs/common",
71
- // ],
72
- // },
73
- modularizeImports: {
74
- "react-icons/?(((\\w*)?/?)*)": {
75
- transform: "@react-icons/all-files/{{ matches.[1] }}/{{member}}",
76
- skipDefaultConversion: true
77
- },
78
- lodash: { transform: "lodash/{{member}}", preventFullImport: true },
79
- ...Object.fromEntries(
80
- [appName, ...libs].reduce(
81
- (acc, lib) => [
82
- ...acc,
83
- [`@${lib}/ui`, { transform: `@${lib}/ui/{{member}}`, skipDefaultConversion: true }],
84
- [`@${lib}/next`, { transform: `@${lib}/next/{{member}}`, skipDefaultConversion: true }],
85
- [`@${lib}/common`, { transform: `@${lib}/common/{{member}}`, skipDefaultConversion: true }],
86
- [`@${lib}/client`, { transform: `@${lib}/lib/{{ camelCase member }}`, skipDefaultConversion: true }]
87
- ],
88
- [
89
- ["@contract", { transform: `@contract/src/{{member}}`, skipDefaultConversion: true }],
90
- [`@akanjs/next`, { transform: `@akanjs/next/src/{{member}}`, skipDefaultConversion: true }],
91
- [`@akanjs/common`, { transform: `@akanjs/common/src/{{member}}`, skipDefaultConversion: true }]
92
- ]
93
- )
94
- ),
95
- ...config.modularizeImports ?? {}
96
- },
97
- images: {
98
- formats: ["image/avif", "image/webp"],
99
- ...config.images ?? {},
100
- remotePatterns: [
101
- ...config.images?.remotePatterns ?? [],
102
- ...routes.map(({ domains }) => [
103
- ...domains.main?.map((domain) => ({ protocol: "https", hostname: `**.${domain}` })) ?? [],
104
- ...domains.develop?.map((domain) => ({ protocol: "https", hostname: `**.${domain}` })) ?? [],
105
- ...domains.debug?.map((domain) => ({ protocol: "https", hostname: `**.${domain}` })) ?? []
106
- ]).flat(),
107
- { protocol: "https", hostname: `**.${devDomain}` }
108
- ]
109
- },
110
- webpack: (config2) => {
111
- config2.resolve.alias.canvas = false;
112
- config2.resolve.alias.encoding = false;
113
- return config2;
114
- },
115
- redirects() {
116
- return routes.map(({ basePath, domains }) => [
117
- { basePath, domain: `${basePath}-debug.${devDomain}` },
118
- { basePath, domain: `${basePath}-develop.${devDomain}` },
119
- { basePath, domain: `${basePath}-main.${devDomain}` },
120
- ...domains.main?.map((domain) => ({ basePath, domain })) ?? [],
121
- ...domains.develop?.map((domain) => ({ basePath, domain })) ?? [],
122
- ...domains.debug?.map((domain) => ({ basePath, domain })) ?? []
123
- ]).flat().map(({ basePath, domain }) => ({
124
- source: `/:locale/${basePath}/:path*`,
125
- has: [{ type: "host", value: domain }],
126
- permanent: true,
127
- destination: "/:locale/:path*"
128
- }));
129
- },
130
- rewrites() {
131
- return routes.map(({ basePath, domains }) => [
132
- { basePath, domain: `${basePath}-debug.${devDomain}` },
133
- { basePath, domain: `${basePath}-develop.${devDomain}` },
134
- { basePath, domain: `${basePath}-main.${devDomain}` },
135
- ...domains.main?.map((domain) => ({ basePath, domain })) ?? [],
136
- ...domains.develop?.map((domain) => ({ basePath, domain })) ?? [],
137
- ...domains.debug?.map((domain) => ({ basePath, domain })) ?? []
138
- ]).flat().map(({ basePath, domain }) => [
139
- {
140
- source: "/:locale",
141
- has: [{ type: "host", value: domain }],
142
- destination: `/:locale/${basePath}`
143
- },
144
- {
145
- source: `/:locale/:path((?!${basePath}$)(?!admin(?:/|$)).*)`,
146
- has: [{ type: "host", value: domain }],
147
- destination: `/:locale/${basePath}/:path*`
148
- }
149
- ]).flat();
150
- }
151
- });
152
- };
153
- // Annotate the CommonJS export names for ESM import in node:
154
- 0 && (module.exports = {
155
- withBase
156
- });
package/src/next.base.ts DELETED
@@ -1,146 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
2
- import withAnalyze from "@next/bundle-analyzer";
3
- import { composePlugins, withNx } from "@nx/next";
4
- import type { NextPlugin } from "@nx/next/src/utils/config";
5
- import type { NextConfig } from "next";
6
- import pwa from "next-pwa";
7
- import runtimeCaching from "next-pwa/cache";
8
-
9
- const commandType = process.env.NX_TASK_TARGET_TARGET?.includes("serve")
10
- ? "serve"
11
- : process.env.NX_TASK_TARGET_TARGET?.includes("build")
12
- ? "build"
13
- : "deploy";
14
- const withPWA = pwa({
15
- dest: "public",
16
- register: true,
17
- skipWaiting: true,
18
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
19
- runtimeCaching,
20
- // disable: commandType === "serve",
21
- });
22
- const devDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? "akanjs.com";
23
- const libs = ["game", "mint", "platform", "social", "shared", "util"];
24
-
25
- /**
26
- * @type { (config: import('@nx/next/plugins/with-nx').WithNxOptions) => import('@nx/next/plugins/with-nx').WithNxOptions }
27
- **/
28
- export const withBase = (
29
- appName: string,
30
- config: NextConfig,
31
- routes: { basePath?: string; domains: { main?: string[]; develop?: string[]; debug?: string[] } }[] = []
32
- ) => {
33
- return composePlugins(
34
- withNx,
35
- withAnalyze({ enabled: process.env.ANALYZE === "true" }) as unknown as NextPlugin,
36
- ...(commandType !== "serve" || process.env.USE_PWA === "true" ? [withPWA as unknown as NextPlugin] : [])
37
- )({
38
- ...config,
39
- env: {
40
- ...config.env,
41
- basePaths: routes.map(({ basePath }) => basePath).join(","),
42
- },
43
- transpilePackages: ["swiper", "ssr-window", "dom7"],
44
- reactStrictMode: commandType === "serve" ? false : true,
45
- nx: { svgr: false },
46
- // experimental: {
47
- // ...(config.experimental ?? {}),
48
- // optimizePackageImports: [
49
- // "react-icons",
50
- // "lodash",
51
- // ...[appName, ...libs].map((lib) => [`@${lib}/ui`, `@${lib}/next`, `@${lib}/common`, `@${lib}/client`]).flat(),
52
- // "@contract",
53
- // "@akanjs/next",
54
- // "@akanjs/common",
55
- // ],
56
- // },
57
- modularizeImports: {
58
- "react-icons/?(((\\w*)?/?)*)": {
59
- transform: "@react-icons/all-files/{{ matches.[1] }}/{{member}}",
60
- skipDefaultConversion: true,
61
- },
62
- lodash: { transform: "lodash/{{member}}", preventFullImport: true },
63
- ...Object.fromEntries(
64
- [appName, ...libs].reduce(
65
- (acc, lib) => [
66
- ...acc,
67
- [`@${lib}/ui`, { transform: `@${lib}/ui/{{member}}`, skipDefaultConversion: true }],
68
- [`@${lib}/next`, { transform: `@${lib}/next/{{member}}`, skipDefaultConversion: true }],
69
- [`@${lib}/common`, { transform: `@${lib}/common/{{member}}`, skipDefaultConversion: true }],
70
- [`@${lib}/client`, { transform: `@${lib}/lib/{{ camelCase member }}`, skipDefaultConversion: true }],
71
- ],
72
- [
73
- ["@contract", { transform: `@contract/src/{{member}}`, skipDefaultConversion: true }],
74
- [`@akanjs/next`, { transform: `@akanjs/next/src/{{member}}`, skipDefaultConversion: true }],
75
- [`@akanjs/common`, { transform: `@akanjs/common/src/{{member}}`, skipDefaultConversion: true }],
76
- ]
77
- )
78
- ),
79
- ...(config.modularizeImports ?? {}),
80
- },
81
- images: {
82
- formats: ["image/avif", "image/webp"],
83
- ...(config.images ?? {}),
84
- remotePatterns: [
85
- ...(config.images?.remotePatterns ?? []),
86
- ...routes
87
- .map(({ domains }) => [
88
- ...(domains.main?.map((domain) => ({ protocol: "https", hostname: `**.${domain}` })) ?? []),
89
- ...(domains.develop?.map((domain) => ({ protocol: "https", hostname: `**.${domain}` })) ?? []),
90
- ...(domains.debug?.map((domain) => ({ protocol: "https", hostname: `**.${domain}` })) ?? []),
91
- ])
92
- .flat(),
93
- { protocol: "https", hostname: `**.${devDomain}` },
94
- ],
95
- },
96
- webpack: (config: NextConfig) => {
97
- // react-pdf error fix
98
- config.resolve.alias.canvas = false;
99
- config.resolve.alias.encoding = false;
100
- return config;
101
- },
102
- redirects() {
103
- return routes
104
- .map(({ basePath, domains }) => [
105
- { basePath, domain: `${basePath}-debug.${devDomain}` },
106
- { basePath, domain: `${basePath}-develop.${devDomain}` },
107
- { basePath, domain: `${basePath}-main.${devDomain}` },
108
- ...(domains.main?.map((domain) => ({ basePath, domain })) ?? []),
109
- ...(domains.develop?.map((domain) => ({ basePath, domain })) ?? []),
110
- ...(domains.debug?.map((domain) => ({ basePath, domain })) ?? []),
111
- ])
112
- .flat()
113
- .map(({ basePath, domain }) => ({
114
- source: `/:locale/${basePath}/:path*`,
115
- has: [{ type: "host", value: domain }],
116
- permanent: true,
117
- destination: "/:locale/:path*",
118
- }));
119
- },
120
- rewrites() {
121
- return routes
122
- .map(({ basePath, domains }) => [
123
- { basePath, domain: `${basePath}-debug.${devDomain}` },
124
- { basePath, domain: `${basePath}-develop.${devDomain}` },
125
- { basePath, domain: `${basePath}-main.${devDomain}` },
126
- ...(domains.main?.map((domain) => ({ basePath, domain })) ?? []),
127
- ...(domains.develop?.map((domain) => ({ basePath, domain })) ?? []),
128
- ...(domains.debug?.map((domain) => ({ basePath, domain })) ?? []),
129
- ])
130
- .flat()
131
- .map(({ basePath, domain }) => [
132
- {
133
- source: "/:locale",
134
- has: [{ type: "host", value: domain }],
135
- destination: `/:locale/${basePath}`,
136
- },
137
- {
138
- source: `/:locale/:path((?!${basePath}$)(?!admin(?:/|$)).*)`,
139
- has: [{ type: "host", value: domain }],
140
- destination: `/:locale/${basePath}/:path*`,
141
- },
142
- ])
143
- .flat();
144
- },
145
- } as unknown as NextConfig);
146
- };
@@ -1,25 +0,0 @@
1
- const path = require("path");
2
- // import type { Config } from "postcss-load-config";
3
-
4
- const withBase = (config = {}) => ({
5
- ...config,
6
- plugins: {
7
- ...(process.env.USE_AKANJS_PKGS === "true"
8
- ? {
9
- "postcss-import": {
10
- resolve(id) {
11
- if (id.startsWith("@akanjs/config/src"))
12
- return path.resolve(__dirname, id.replace("@akanjs/config/src/", ""));
13
- else return id;
14
- },
15
- },
16
- }
17
- : {}),
18
- "@tailwindcss/postcss": process.env.NX_WORKSPACE_ROOT
19
- ? { base: path.join(process.env.NX_WORKSPACE_ROOT, "./") }
20
- : {},
21
- ...(config.plugins ?? {}),
22
- },
23
- });
24
-
25
- module.exports = { withBase };