@@ -110,7 +110,7 @@ export function constructWebpackConfigFunction(
110110 appDirPath = path . join ( projectDir , 'src' , 'app' ) ;
111111 }
112112
113- const apiRoutesPath = path . join ( pagesDirPath , 'api' , '/' ) ;
113+ const apiRoutesPath = path . join ( pagesDirPath , 'api' ) ;
114114
115115 const middlewareJsPath = path . join ( pagesDirPath , '..' , 'middleware.js' ) ;
116116 const middlewareTsPath = path . join ( pagesDirPath , '..' , 'middleware.ts' ) ;
@@ -148,8 +148,8 @@ export function constructWebpackConfigFunction(
148148 test : resourcePath => {
149149 const normalizedAbsoluteResourcePath = normalizeLoaderResourcePath ( resourcePath ) ;
150150 return (
151- normalizedAbsoluteResourcePath . startsWith ( pagesDirPath ) &&
152- ! normalizedAbsoluteResourcePath . startsWith ( apiRoutesPath ) &&
151+ normalizedAbsoluteResourcePath . startsWith ( pagesDirPath + path . sep ) &&
152+ ! normalizedAbsoluteResourcePath . startsWith ( apiRoutesPath + path . sep ) &&
153153 dotPrefixedPageExtensions . some ( ext => normalizedAbsoluteResourcePath . endsWith ( ext ) )
154154 ) ;
155155 } ,
@@ -193,7 +193,7 @@ export function constructWebpackConfigFunction(
193193 test : resourcePath => {
194194 const normalizedAbsoluteResourcePath = normalizeLoaderResourcePath ( resourcePath ) ;
195195 return (
196- normalizedAbsoluteResourcePath . startsWith ( apiRoutesPath ) &&
196+ normalizedAbsoluteResourcePath . startsWith ( apiRoutesPath + path . sep ) &&
197197 dotPrefixedPageExtensions . some ( ext => normalizedAbsoluteResourcePath . endsWith ( ext ) )
198198 ) ;
199199 } ,
@@ -238,7 +238,7 @@ export function constructWebpackConfigFunction(
238238 // ".js, .jsx, or .tsx file extensions can be used for Pages"
239239 // 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.
240240 return (
241- normalizedAbsoluteResourcePath . startsWith ( appDirPath ) &&
241+ normalizedAbsoluteResourcePath . startsWith ( appDirPath + path . sep ) &&
242242 ! ! 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 ) $ / )
243243 ) ;
244244 } ,
0 commit comments