Skip to content

Commit fe4d528

Browse files
authored
Merge pull request #78 from keepsimpleio/dev
Optimization
2 parents 6045c05 + 125d9aa commit fe4d528

272 files changed

Lines changed: 522 additions & 1779 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,6 @@ dist
116116
package-lock.json
117117

118118
.claude/settings.local.json
119+
120+
# Playwright
121+
playwright-report/

next.config.js

Lines changed: 53 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,64 @@
1-
/* eslint-disable @typescript-eslint/no-require-imports */
21
const dotenv = require('dotenv');
32
const path = require('path');
43
const { existsSync } = require('fs');
4+
const withBundleAnalyzer = require('@next/bundle-analyzer')({
5+
enabled: process.env.ANALYZE === 'true',
6+
});
57

6-
module.exports = async () => {
8+
module.exports = withBundleAnalyzer({
9+
// Move env loading to the top level, outside the config
10+
...loadEnv(),
11+
12+
i18n: {
13+
locales: ['en', 'ru', 'hy'],
14+
defaultLocale: 'en',
15+
},
16+
assetPrefix: process.env.NODE_ENV === 'development' ? '' : '/keepsimple_next',
17+
async rewrites() {
18+
return [
19+
{ source: '/assets/:path*', destination: '/keepsimple_/assets/:path*' },
20+
{ source: '/fonts/:path*', destination: '/keepsimple_/fonts/:path*' },
21+
{ source: '/audio/:path*', destination: '/keepsimple_/audio/:path*' },
22+
{ source: '/static/:path*', destination: '/keepsimple_/static/:path*' },
23+
{ source: '/robots.txt', destination: '/keepsimple_/robots.txt' },
24+
];
25+
},
26+
env: {
27+
NEXTAUTH_URL: process.env.NEXTAUTH_URL,
28+
},
29+
compiler: {
30+
removeConsole: process.env.NODE_ENV === 'prod',
31+
},
32+
eslint: {
33+
ignoreDuringBuilds: true,
34+
},
35+
images: {
36+
domains: [
37+
'lh3.googleusercontent.com',
38+
'cdn.discordapp.com',
39+
'strapi.keepsimple.io',
40+
'staging-strapi.keepsimple.io',
41+
],
42+
deviceSizes: [480, 640, 750, 828, 1080, 1200, 1920, 2048, 3840],
43+
},
44+
webpack(config) {
45+
config.module.rules.push({
46+
test: /\.svg$/i,
47+
issuer: /\.[jt]sx?$/,
48+
use: ['@svgr/webpack'],
49+
});
50+
return config;
51+
},
52+
productionBrowserSourceMaps: true,
53+
});
54+
55+
function loadEnv() {
756
const envFile = `.env.${process.env.APP_ENV || 'local'}`;
857
const envPath = path.join(__dirname, envFile);
9-
const isLocal = process.env.NODE_ENV === 'development';
10-
1158
if (existsSync(envPath)) {
1259
dotenv.config({ path: envPath });
1360
} else {
1461
console.error(`Env file not found: ${envPath}`);
1562
}
16-
17-
return {
18-
i18n: {
19-
locales: ['en', 'ru', 'hy'],
20-
defaultLocale: 'en',
21-
},
22-
assetPrefix: isLocal ? '' : '/keepsimple_next',
23-
async rewrites() {
24-
return [
25-
{
26-
source: '/assets/:path*',
27-
destination: '/keepsimple_/assets/:path*',
28-
},
29-
{
30-
source: '/fonts/:path*',
31-
destination: '/keepsimple_/fonts/:path*',
32-
},
33-
{
34-
source: '/audio/:path*',
35-
destination: '/keepsimple_/audio/:path*',
36-
},
37-
{
38-
source: '/static/:path*',
39-
destination: '/keepsimple_/static/:path*',
40-
},
41-
{
42-
source: '/robots.txt',
43-
destination: '/keepsimple_/robots.txt',
44-
},
45-
];
46-
},
47-
env: {
48-
NEXTAUTH_URL: process.env.NEXTAUTH_URL,
49-
},
50-
compiler: {
51-
removeConsole:
52-
process.env.NODE_ENV === 'prod' ? { exclude: ['error'] } : false,
53-
},
54-
eslint: {
55-
ignoreDuringBuilds: true, // useful in CI/CD
56-
},
57-
images: {
58-
domains: [
59-
'lh3.googleusercontent.com',
60-
'cdn.discordapp.com',
61-
'strapi.keepsimple.io',
62-
'staging-strapi.keepsimple.io',
63-
],
64-
},
65-
webpack(config) {
66-
config.module.rules.push({
67-
test: /\.svg$/i,
68-
issuer: /\.[jt]sx?$/,
69-
use: ['@svgr/webpack'],
70-
});
71-
72-
return config;
73-
},
74-
75-
productionBrowserSourceMaps: true,
76-
};
77-
};
63+
return {};
64+
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"prepare": "husky install"
2222
},
2323
"dependencies": {
24+
"@next/bundle-analyzer": "^16.2.3",
2425
"@svgr/webpack": "^8.1.0",
2526
"classnames": "2.3.1",
2627
"cookie": "0.6.0",
-2.54 MB
Loading
-22 KB
Loading
-643 Bytes
Loading
-542 Bytes
Loading
-588 Bytes
Loading
-499 Bytes
Loading
-42.4 KB
Loading

0 commit comments

Comments
 (0)