Merge pull request #204 from nolanlawson/ignore-source-maps

Add support for sourcemap *.map files
This commit is contained in:
Rich Harris
2018-03-18 21:23:26 -04:00
committed by GitHub
3 changed files with 13 additions and 2 deletions

View File

@@ -80,6 +80,11 @@ export default function middleware({ routes, store }: {
cache_control: 'max-age=600'
}),
fs.existsSync(path.join(output, 'service-worker.js.map')) && serve({
pathname: '/service-worker.js.map',
cache_control: 'max-age=600'
}),
serve({
prefix: '/client/',
cache_control: 'max-age=31536000'
@@ -147,6 +152,7 @@ function get_route_handler(chunks: Record<string, string>, routes: RouteObject[]
// TODO detect other stuff we can preload? images, CSS, fonts?
const link = []
.concat(chunks.main, chunks[route.id])
.filter(file => !file.match(/\.map$/))
.map(file => `<${req.baseUrl}/client/${file}>;rel="preload";as="script"`)
.join(', ');
@@ -231,6 +237,7 @@ function get_route_handler(chunks: Record<string, string>, routes: RouteObject[]
let scripts = []
.concat(chunks.main) // chunks main might be an array. it might not! thanks, webpack
.filter(file => !file.match(/\.map$/))
.map(file => `<script src='${req.baseUrl}/client/${file}'></script>`)
.join('');
@@ -406,4 +413,4 @@ function try_serialize(data: any) {
} catch (err) {
return null;
}
}
}