Skip to content

Commit e1f1ec9

Browse files
authored
Fix for the Next.js configuration. (#656)
1 parent 17feb37 commit e1f1ec9

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
1717

1818
## Unreleased
1919

20+
## [0.21.4](https://github.com/o1-labs/zkapp-cli/compare/0.21.3...0.21.4) - 2024-05-21
21+
22+
### Fixed
23+
24+
- Fixed the Next.js configuration. [#656](https://github.com/o1-labs/zkapp-cli/pull/656)
25+
2026
## [0.21.3](https://github.com/o1-labs/zkapp-cli/compare/0.21.2...0.21.3) - 2024-05-20
2127

2228
### Fixed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zkapp-cli",
3-
"version": "0.21.3",
3+
"version": "0.21.4",
44
"description": "CLI to create zkApps (zero-knowledge apps) for Mina Protocol",
55
"homepage": "https://github.com/o1-labs/zkapp-cli/",
66
"keywords": [

src/lib/project.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,23 @@ async function scaffoldNext(projectName) {
426426
'utf8'
427427
);
428428

429-
let newNextConfig = nextConfig.replace(
429+
let newNextConfig = `import path from 'node:path';
430+
import { fileURLToPath } from 'node:url';
431+
432+
const __filename = fileURLToPath(import.meta.url);
433+
const __dirname = path.dirname(__filename);
434+
435+
`;
436+
newNextConfig += nextConfig.replace(
430437
/^};(.*?)$/gm, // Search for the last '};' in the file.
431438
`
432-
webpack(config) {
439+
webpack(config, { isServer }) {
440+
if (!isServer) {
441+
config.resolve.alias = {
442+
...config.resolve.alias,
443+
o1js: path.resolve(__dirname, 'node_modules/o1js/dist/web/index.js'),
444+
};
445+
}
433446
config.experiments = { ...config.experiments, topLevelAwait: true };
434447
return config;
435448
},
@@ -451,7 +464,7 @@ async function scaffoldNext(projectName) {
451464
],
452465
},
453466
];
454-
}
467+
},
455468
};`
456469
);
457470

@@ -549,7 +562,7 @@ async function scaffoldNext(projectName) {
549562
);
550563

551564
let newNextConfig = nextConfig.replace(
552-
' }\n};',
565+
' },\n};',
553566
` },
554567
images: {
555568
unoptimized: true,
@@ -560,7 +573,7 @@ async function scaffoldNext(projectName) {
560573
* when deployed to GitHub Pages. The assetPrefix needs to be added manually to any assets
561574
* if they're not loaded by Next.js' automatic handling (for example, in CSS files or in a <img> element).
562575
* The 'ghp-postbuild.js' script in this project prepends the repo name to asset urls in the built css files
563-
* after runing 'npm run deploy'.
576+
* after running 'npm run deploy'.
564577
*/
565578
basePath: process.env.NODE_ENV === 'production' ? '/${projectName}' : '', // update if your repo name changes for 'npm run deploy' to work correctly
566579
assetPrefix: process.env.NODE_ENV === 'production' ? '/${projectName}/' : '', // update if your repo name changes for 'npm run deploy' to work correctly
@@ -573,7 +586,7 @@ async function scaffoldNext(projectName) {
573586
return config;`
574587
);
575588

576-
// update papage extensions
589+
// update page extensions
577590
newNextConfig = newNextConfig.replace(
578591
'reactStrictMode: false,',
579592
`reactStrictMode: false,

0 commit comments

Comments
 (0)