Webpack: Only serve lib.js under root path

20c7286ea13022452f644bcd7511fd09a4abb82b

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +2 -1Showing whitespace changes
src/middleware/webpack-serve.js+2 -1
@@ -14,8 +14,9 @@ export default function getWebpackServeMiddleware() {
14 const publicLibConfig = getPublicLibConfig();14 const publicLibConfig = getPublicLibConfig();
15 const outputPath = publicLibConfig.output?.path;15 const outputPath = publicLibConfig.output?.path;
16 const outputFile = publicLibConfig.output?.filename;16 const outputFile = publicLibConfig.output?.filename;
17 const parsedPath = path.parse(req.path);
1718
18 if (req.method === 'GET' && path.parse(req.path).base === outputFile) {19 if (req.method === 'GET' && parsedPath.dir === '/' && parsedPath.base === outputFile) {
19 return res.sendFile(outputFile, { root: outputPath });20 return res.sendFile(outputFile, { root: outputPath });
20 }21 }
2122