11// eslint-disable-next-line @typescript-eslint/no-var-requires
2- // const path = require('path');
3- // next-compose-plugins
4- // const withPlugins = require('next-compose-plugins');
5- // next-images
6- // const withImages = require('next-images')
2+ const i18NextConfig = require ( './next-i18next.config' ) ;
3+ const { i18n } = i18NextConfig ;
4+
75const isProd = process . env . NODE_ENV === 'production' ;
86
97const BASE_PREFIX_APP = '/nextjs-demo' ;
@@ -16,12 +14,14 @@ const BASE_PREFIX_APP_WITH_VERSION = `${BASE_PREFIX_APP}${BASE_VERSION_ONLY}`;
1614 * @type {import('next').NextConfig }
1715 */
1816module . exports = {
19- output : 'standalone' ,
17+ ... ( isProd ? { output : 'standalone' } : { } ) ,
2018 outputFileTracing : isProd ,
2119 experimental : {
2220 bundleServerPackages : isProd ,
2321 } ,
2422
23+ i18n,
24+
2525 // We want the static assets, api calls, and _next/data calls
2626 // to have /nextjs-demo/0.0.0/ as the prefix so they route cleanly
2727 // to an isolated folder on the S3 bucket and to a specific
@@ -61,41 +61,49 @@ module.exports = {
6161 // in the path, which is perfect because that's where the assets
6262 // will be on the S3 bucket.
6363 async rewrites ( ) {
64- return [
65- {
66- /** Static Assets and getServerSideProps (_next/data/) */
67- source : `${ BASE_PREFIX_APP_WITH_VERSION } /_next/:path*` ,
68- destination : `/_next/:path*` ,
69- } ,
70- {
71- /** Image optimizer (not tested yet) */
72- source : `${ BASE_VERSION_ONLY } /_next/image/:query*` ,
73- destination : `/_next/image/:query*` ,
74- } ,
75- {
76- // Images
77- // Only used for local development
78- // On deployed environments, the images are served from S3
79- // and image requests will never reach this rewrite
80- source : `${ BASE_PREFIX_APP_WITH_VERSION } /images/:query*` ,
81- destination : `/images/:query*` ,
82- } ,
83- {
84- // Favicon
85- // Only used for local development
86- source : `${ BASE_PREFIX_APP_WITH_VERSION } /favicon.ico` ,
87- destination : `/favicon.ico` ,
88- } ,
89- /** Api Calls */
90- {
91- source : `${ BASE_VERSION_ONLY } /api/:path*` ,
92- destination : `/api/:path*` ,
93- } ,
94- ] ;
64+ return {
65+ beforeFiles : [
66+ {
67+ /** Static Assets and getServerSideProps (_next/data/) */
68+ source : `${ BASE_PREFIX_APP_WITH_VERSION } /_next/static/:path*` ,
69+ destination : `/_next/static/:path*` ,
70+ } ,
71+ {
72+ // Favicon
73+ // Only used for local development
74+ source : `${ BASE_PREFIX_APP_WITH_VERSION } /favicon.ico` ,
75+ destination : `/favicon.ico` ,
76+ } ,
77+ {
78+ // Images
79+ // Only used for local development
80+ // On deployed environments, the images are served from S3
81+ // and image requests will never reach this rewrite
82+ source : `${ BASE_PREFIX_APP_WITH_VERSION } /images/:query*` ,
83+ destination : `/images/:query*` ,
84+ } ,
85+ ] ,
86+ afterFiles : [
87+ {
88+ /** Image optimizer (not tested yet) */
89+ source : `${ BASE_VERSION_ONLY } /_next/image/:query*` ,
90+ destination : `/_next/image/:query*` ,
91+ } ,
92+ /** Api Calls */
93+ {
94+ source : `${ BASE_VERSION_ONLY } /api/:path*` ,
95+ destination : `/api/:path*` ,
96+ } ,
97+ ] ,
98+ } ;
9599 } ,
96100
97101 publicRuntimeConfig : {
98102 // Will be available on both server and client
99103 staticFolder : isProd ? BASE_PREFIX_APP_WITH_VERSION : BASE_PREFIX_APP_WITH_VERSION ,
100104 } ,
105+
106+ typescript : {
107+ tsconfigPath : './tsconfig.json' ,
108+ } ,
101109} ;
0 commit comments