Skip to content

Commit 1a15c93

Browse files
committed
chore: enhance Next.js configuration for improved module resolution
- Update next.config.js to include explicit alias configurations for better compatibility in CI/CD environments. - Ensure proper module resolution order by adjusting the modules array. - Modify GitHub Actions workflow to prevent auto-injection of conflicting Next.js configurations, allowing for manual management.
1 parent b81a0d9 commit 1a15c93

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

.github/workflows/nextjs.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,8 @@ jobs:
5555
cache: ${{ steps.detect-package-manager.outputs.manager }}
5656
- name: Setup Pages
5757
uses: actions/configure-pages@v3
58-
with:
59-
# Automatically inject basePath in your Next.js configuration file and disable
60-
# server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
61-
#
62-
# You may remove this line if you want to manage the configuration yourself.
63-
static_site_generator: next
58+
# Removed static_site_generator to prevent auto-injection of conflicting configs
59+
# We manage our own Next.js configuration in next.config.js
6460
- name: Restore cache
6561
uses: actions/cache@v3
6662
with:

jsconfig.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"compilerOptions": {
3+
"baseUrl": ".",
4+
"paths": {
5+
"@/*": ["./src/*"],
6+
"@/components": ["./src/components"],
7+
"@/data/*": ["./src/data/*"]
8+
}
9+
},
10+
"include": ["src/**/*"],
11+
"exclude": ["node_modules", ".next", "out"]
12+
}

next.config.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,23 @@ const nextConfig = {
99
transpilePackages: ['@tabler/icons-react'],
1010

1111
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
12-
// Fix for module resolution
12+
// Enhanced module resolution for CI/CD environments
1313
config.resolve.fallback = {
1414
...config.resolve.fallback,
1515
fs: false,
1616
}
17+
18+
// Explicit alias configuration for better CI compatibility
19+
config.resolve.alias = {
20+
...config.resolve.alias,
21+
'@': require('path').resolve(__dirname, 'src'),
22+
'@/components': require('path').resolve(__dirname, 'src/components'),
23+
'@/data': require('path').resolve(__dirname, 'src/data'),
24+
}
25+
26+
// Ensure proper module resolution order
27+
config.resolve.modules = [require('path').resolve(__dirname, 'src'), 'node_modules']
28+
1729
return config
1830
},
1931
}

0 commit comments

Comments
 (0)