critters
critters copied to clipboard
Fails to locate css for html files in subdirectories
The html file generated is in a subdirectory of the main output directory (/project-root/dist/):
/project-root/dist/imprint/index.html
The css is located in the output directory:
/project-root/dist/styles.css
So the html generated by webpack references relatively:
<link href="../styles.css" rel="stylesheet">
Critters resolves this as follows:
filename = path.resolve(outputPath, href.replace(/^\//, ""));
Leading to path.resolve(/project-root/dist/../styles.css); which generates the non-existant /project-root/styles.css
This is broken, because it tries to resolve relatively to the main output directory and not the real location of the html-file.
Setting a public path in webpack can circumvent the problem, because it generates absolute urls:
output: { publicPath: "/" }
Nice catch! I always use publicPath since without it, client-side routing breaks resource paths. This should be pretty simple to fix.
+1