Skip to content

Commit

Permalink
feat(nextjs): add support for typescript Next.js config file (#28709)
Browse files Browse the repository at this point in the history
<!-- 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
  • Loading branch information
ndcunningham authored Oct 30, 2024
1 parent 63b745e commit 51bed0e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/generated/packages/next/documents/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ The `@nx/next` plugin will create tasks for any project that has a Next.js confi
- `next.config.js`
- `next.config.cjs`
- `next.config.mjs`
- `next.config.ts`

### View Inferred Tasks

Expand Down
1 change: 1 addition & 0 deletions docs/shared/packages/next/plugin-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ The `@nx/next` plugin will create tasks for any project that has a Next.js confi
- `next.config.js`
- `next.config.cjs`
- `next.config.mjs`
- `next.config.ts`

### View Inferred Tasks

Expand Down
4 changes: 2 additions & 2 deletions packages/devkit/src/utils/add-plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('addPlugin', () => {
},
};
createNodes = [
'**/next.config.{js,cjs,mjs}',
'**/next.config.{ts,js,cjs,mjs}',
(_, { targetName }) => [
[
'app1/next.config.js',
Expand Down Expand Up @@ -300,7 +300,7 @@ describe('addPlugin', () => {
});

createNodes = [
'**/next.config.{js,cjs,mjs}',
'**/next.config.{ts,js,cjs,mjs}',
() => [
[
'app1/next.config.js',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,12 @@ export function findNextConfigPath(
);
}

const candidates = ['next.config.js', 'next.config.cjs', 'next.config.mjs'];
const candidates = [
'next.config.js',
'next.config.cjs',
'next.config.mjs',
'next.config.ts',
];
for (const candidate of candidates) {
if (existsSync(join(dirname, candidate))) return candidate;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface NextPluginOptions {
serveStaticTargetName?: string;
}

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

function readTargetsCache(
cachePath: string
Expand Down

0 comments on commit 51bed0e

Please sign in to comment.