@korioinc/next-conf 1.0.1 → 1.0.2
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.
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import type { NextConfig } from 'next';
|
|
2
2
|
export interface WithConfigOptions {
|
|
3
3
|
configFileName?: string;
|
|
4
|
-
/**
|
|
5
|
-
* Path or filename for the consumer's Lingui config.
|
|
6
|
-
* Defaults to `lingui.config.ts` at the project root.
|
|
7
|
-
*/
|
|
8
4
|
linguiConfigFileName?: string;
|
|
5
|
+
linguiCatalogsPath?: string;
|
|
9
6
|
}
|
|
10
7
|
/**
|
|
11
8
|
* Next.js configuration plugin that injects webpack aliases
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-config.d.ts","sourceRoot":"","sources":["../../src/plugin/with-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AA2BvC,MAAM,WAAW,iBAAiB;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB
|
|
1
|
+
{"version":3,"file":"with-config.d.ts","sourceRoot":"","sources":["../../src/plugin/with-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AA2BvC,MAAM,WAAW,iBAAiB;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAAC,UAAU,GAAE,UAAe,EAAE,OAAO,GAAE,iBAAsB,GAAG,UAAU,CAsFxG"}
|
|
@@ -18,7 +18,7 @@ import * as path from 'path';
|
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
20
|
export function withNextKitConf(nextConfig = {}, options = {}) {
|
|
21
|
-
const { configFileName = 'next-kit.config.ts', linguiConfigFileName = 'lingui.config.ts' } = options;
|
|
21
|
+
const { configFileName = 'next-kit.config.ts', linguiConfigFileName = 'lingui.config.ts', linguiCatalogsPath = 'lang', } = options;
|
|
22
22
|
return {
|
|
23
23
|
...nextConfig,
|
|
24
24
|
// Turbopack configuration for development
|
|
@@ -36,6 +36,12 @@ export function withNextKitConf(nextConfig = {}, options = {}) {
|
|
|
36
36
|
'lingui.config': linguiConfigFileName.startsWith('.') || linguiConfigFileName.startsWith('/')
|
|
37
37
|
? linguiConfigFileName
|
|
38
38
|
: `./${linguiConfigFileName}`,
|
|
39
|
+
// Lingui catalogs alias
|
|
40
|
+
// Prefer existing alias; else use provided/default path (as a specifier)
|
|
41
|
+
'lingui.locale-path': nextConfig.turbopack?.resolveAlias?.['lingui.locale-path'] ??
|
|
42
|
+
(linguiCatalogsPath.startsWith('.') || linguiCatalogsPath.startsWith('/')
|
|
43
|
+
? linguiCatalogsPath
|
|
44
|
+
: `./${linguiCatalogsPath}`),
|
|
39
45
|
},
|
|
40
46
|
},
|
|
41
47
|
// Webpack configuration for production builds
|
|
@@ -64,6 +70,12 @@ export function withNextKitConf(nextConfig = {}, options = {}) {
|
|
|
64
70
|
if (config.resolve?.alias) {
|
|
65
71
|
config.resolve.alias['lingui.config'] = userLinguiConfigPath;
|
|
66
72
|
}
|
|
73
|
+
// Lingui catalogs alias for Webpack (prefer existing)
|
|
74
|
+
if (config.resolve?.alias) {
|
|
75
|
+
const existing = config.resolve.alias['lingui.locale-path'];
|
|
76
|
+
const desired = existing || path.resolve(cwd, linguiCatalogsPath);
|
|
77
|
+
config.resolve.alias['lingui.locale-path'] = desired;
|
|
78
|
+
}
|
|
67
79
|
// Call the original webpack function if it exists
|
|
68
80
|
if (typeof nextConfig.webpack === 'function') {
|
|
69
81
|
return nextConfig.webpack(config, options);
|