Skip to content

Commit 51bed0e

Browse files
authored
feat(nextjs): add support for typescript Next.js config file (#28709)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #28572
1 parent 63b745e commit 51bed0e

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

docs/generated/packages/next/documents/overview.md

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ The `@nx/next` plugin will create tasks for any project that has a Next.js confi
6060
- `next.config.js`
6161
- `next.config.cjs`
6262
- `next.config.mjs`
63+
- `next.config.ts`
6364

6465
### View Inferred Tasks
6566

docs/shared/packages/next/plugin-overview.md

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ The `@nx/next` plugin will create tasks for any project that has a Next.js confi
6060
- `next.config.js`
6161
- `next.config.cjs`
6262
- `next.config.mjs`
63+
- `next.config.ts`
6364

6465
### View Inferred Tasks
6566

packages/devkit/src/utils/add-plugin.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('addPlugin', () => {
5454
},
5555
};
5656
createNodes = [
57-
'**/next.config.{js,cjs,mjs}',
57+
'**/next.config.{ts,js,cjs,mjs}',
5858
(_, { targetName }) => [
5959
[
6060
'app1/next.config.js',
@@ -300,7 +300,7 @@ describe('addPlugin', () => {
300300
});
301301

302302
createNodes = [
303-
'**/next.config.{js,cjs,mjs}',
303+
'**/next.config.{ts,js,cjs,mjs}',
304304
() => [
305305
[
306306
'app1/next.config.js',

packages/next/src/executors/build/lib/create-next-config-file.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,12 @@ export function findNextConfigPath(
155155
);
156156
}
157157

158-
const candidates = ['next.config.js', 'next.config.cjs', 'next.config.mjs'];
158+
const candidates = [
159+
'next.config.js',
160+
'next.config.cjs',
161+
'next.config.mjs',
162+
'next.config.ts',
163+
];
159164
for (const candidate of candidates) {
160165
if (existsSync(join(dirname, candidate))) return candidate;
161166
}

packages/next/src/plugins/plugin.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export interface NextPluginOptions {
2929
serveStaticTargetName?: string;
3030
}
3131

32-
const nextConfigBlob = '**/next.config.{js,cjs,mjs}';
32+
const nextConfigBlob = '**/next.config.{ts,js,cjs,mjs}';
3333

3434
function readTargetsCache(
3535
cachePath: string

0 commit comments

Comments
 (0)