-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathnext.config.prod.js
More file actions
133 lines (114 loc) · 4.07 KB
/
Copy pathnext.config.prod.js
File metadata and controls
133 lines (114 loc) · 4.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
const withNextIntl = require('next-intl/plugin')('./src/i18n/request.ts');
/** @type {import('next').NextConfig} */
const nextConfig = {
// ✅ PRODUCTION: Vérification TypeScript activée
typescript: {
ignoreBuildErrors: false,
},
images: {
remotePatterns: [
{ protocol: 'https', hostname: 'pbs.twimg.com' },
{ protocol: 'https', hostname: 'abs.twimg.com' },
{ protocol: 'https', hostname: 'cdn.bsky.app' },
],
},
// Désactive le header X-Powered-By pour la sécurité
poweredByHeader: false,
// Active la compression gzip
compress: true,
// Transpile embedding-atlas to avoid minification issues with its toolbar
transpilePackages: ['embedding-atlas'],
experimental: {
staleTimes: {
dynamic: 30, // 30 secondes pour les pages dynamiques
static: 300, // 5 minutes pour les pages statiques
},
optimizePackageImports: ['lucide-react', '@heroicons/react', 'react-icons'],
},
turbopack: {
resolveAlias: {
worker_threads: './src/shims/worker_threads-browser.js',
},
},
// ✅ Webpack config pour production (embedding-atlas + duckdb)
webpack: (config, { isServer }) => {
// Fix pour embedding-atlas: résout le conflit avec asset/inline modules
// https://github.com/vercel/next.js/discussions/36981
if (config.module.generator) {
config.module.generator['asset/resource'] = config.module.generator.asset;
config.module.generator['asset/source'] = config.module.generator.asset;
delete config.module.generator.asset;
}
if (!isServer) {
config.resolve = config.resolve || {};
config.resolve.fallback = {
...(config.resolve.fallback || {}),
worker_threads: false,
};
}
// Fix pour embedding-atlas: isoler dans son propre chunk chargé dynamiquement
// et exclure ce module spécifique de la minification via Terser.
// https://github.com/vercel/next.js/issues/59594
if (!isServer) {
const TerserPlugin = require('terser-webpack-plugin');
// Forcer embedding-atlas dans son propre chunk pour le lazy loading
config.optimization.splitChunks = {
...config.optimization.splitChunks,
cacheGroups: {
...config.optimization.splitChunks?.cacheGroups,
embeddingAtlas: {
test: /[\\/]node_modules[\\/]embedding-atlas[\\/]/,
name: 'embedding-atlas',
chunks: 'async', // uniquement pour les imports dynamiques
priority: 50,
enforce: true,
},
},
};
// Utiliser Terser et exclure embedding-atlas de la minification
config.optimization.minimizer = [
new TerserPlugin({
exclude: /[\\/]node_modules[\\/]embedding-atlas[\\/]/,
terserOptions: {
compress: true,
mangle: true,
},
}),
];
}
// Ignore les warnings de duckdb-wasm
config.ignoreWarnings = [
{ module: /@duckdb\/duckdb-wasm/ },
];
// Ne pas bundler ces packages côté serveur
if (isServer) {
config.externals = [
...(config.externals || []),
'@duckdb/duckdb-wasm',
];
}
return config;
},
// Headers de sécurité
headers: async () => [
{
source: '/:path*',
headers: [
{ key: 'Strict-Transport-Security', value: 'max-age=63072000; includeSubDomains; preload' },
{ key: 'X-DNS-Prefetch-Control', value: 'on' },
{ key: 'X-XSS-Protection', value: '1; mode=block' },
{ key: 'X-Frame-Options', value: 'DENY' },
{ key: 'X-Content-Type-Options', value: 'nosniff' },
{ key: 'Referrer-Policy', value: 'origin-when-cross-origin' },
{ key: 'Permissions-Policy', value: 'camera=(), microphone=(), geolocation=()' },
],
},
],
// Rewrites pour les favicons avec préfixe locale (évite 404 sur /fr/favicon.svg)
rewrites: async () => [
{ source: '/:locale/favicon.svg', destination: '/favicon.svg' },
{ source: '/:locale/favicon.ico', destination: '/favicon.ico' },
],
output: 'standalone',
};
module.exports = withNextIntl(nextConfig);