@@ -110,7 +110,7 @@ export function constructWebpackConfigFunction(
110
110
appDirPath = path . join ( projectDir , 'src' , 'app' ) ;
111
111
}
112
112
113
- const apiRoutesPath = path . join ( pagesDirPath , 'api' , '/' ) ;
113
+ const apiRoutesPath = path . join ( pagesDirPath , 'api' ) ;
114
114
115
115
const middlewareJsPath = path . join ( pagesDirPath , '..' , 'middleware.js' ) ;
116
116
const middlewareTsPath = path . join ( pagesDirPath , '..' , 'middleware.ts' ) ;
@@ -148,8 +148,8 @@ export function constructWebpackConfigFunction(
148
148
test : resourcePath => {
149
149
const normalizedAbsoluteResourcePath = normalizeLoaderResourcePath ( resourcePath ) ;
150
150
return (
151
- normalizedAbsoluteResourcePath . startsWith ( pagesDirPath ) &&
152
- ! normalizedAbsoluteResourcePath . startsWith ( apiRoutesPath ) &&
151
+ normalizedAbsoluteResourcePath . startsWith ( pagesDirPath + path . sep ) &&
152
+ ! normalizedAbsoluteResourcePath . startsWith ( apiRoutesPath + path . sep ) &&
153
153
dotPrefixedPageExtensions . some ( ext => normalizedAbsoluteResourcePath . endsWith ( ext ) )
154
154
) ;
155
155
} ,
@@ -193,7 +193,7 @@ export function constructWebpackConfigFunction(
193
193
test : resourcePath => {
194
194
const normalizedAbsoluteResourcePath = normalizeLoaderResourcePath ( resourcePath ) ;
195
195
return (
196
- normalizedAbsoluteResourcePath . startsWith ( apiRoutesPath ) &&
196
+ normalizedAbsoluteResourcePath . startsWith ( apiRoutesPath + path . sep ) &&
197
197
dotPrefixedPageExtensions . some ( ext => normalizedAbsoluteResourcePath . endsWith ( ext ) )
198
198
) ;
199
199
} ,
@@ -238,7 +238,7 @@ export function constructWebpackConfigFunction(
238
238
// ".js, .jsx, or .tsx file extensions can be used for Pages"
239
239
// https://beta.nextjs.org/docs/routing/pages-and-layouts#pages:~:text=.js%2C%20.jsx%2C%20or%20.tsx%20file%20extensions%20can%20be%20used%20for%20Pages.
240
240
return (
241
- normalizedAbsoluteResourcePath . startsWith ( appDirPath ) &&
241
+ normalizedAbsoluteResourcePath . startsWith ( appDirPath + path . sep ) &&
242
242
! ! normalizedAbsoluteResourcePath . match ( / [ \\ / ] ( p a g e | l a y o u t | l o a d i n g | h e a d | n o t - f o u n d ) \. ( j s | j s x | t s x ) $ / )
243
243
) ;
244
244
} ,
0 commit comments