-
-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some paths in webpack configs aren't matched on Windows #453
Comments
Thanks for this! Can you try the following for me: const path = require('path');
//...
let normal = path.posix.normalize(filename);
let relative = normal.replace(src, '');
return normal.includes('/routes/') && 'route-' + relative.replace(/(^\/(routes|components\/(routes|async))\/|(\/index)?\.js$)/g, ''); |
That doesn't fix it, unfortunately. Relevant PR: nodejs/node#12700. |
Ah, thanks! TIL :D Good reason I always avoided posix before. How about this, the more cumbersome route: const RGX = /[\\|\/]/g;
const toNorm = str => path.normalize(str).replace(RGX, '/');
// ...
filename = toNorm(filename);
if (!!~filename.indexOf('/routes/') return false;
let relative = filename.replace(toNorm(src), '');
return 'route-' + relative.replace(/(^\/(routes|components\/(routes|async))\/|(\/index)?\.js$)/g, '');
|
It works if I replace I can work on this myself and submit a PR when I have enough time, if you'd prefer that. Also, TIL about |
Great! You're welcome to open a pull request for that, or else I'll do it later. Sorry about that lol, on my phone |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
I discovered this bug because routes are named
*.chunk.*.js
instead ofroute-*.js
in the build output. This happens because Windows' backslash-delimited file paths (e.g.C:\Users\me\dev\project\src\routes\home\index.js
aren't matched by these strings and regexes:https://github.com/developit/preact-cli/blob/9eb46228922b05ecf88c0803a64f8fa5f04b2ab7/src/lib/webpack/webpack-client-config.js#L55-L58
There are probably more occurences of this throughout the webpack configs.
If the current behavior is a bug, please provide the steps to reproduce.
preact create default test
on Windowscd test
,npm install
npm run build
build
folder, route chunks aren't prefixed withroute-
What is the expected behavior?
In this specific case, routes should be prefixed with
route-
, like on UNIX systems.Generally, both
/
and\
-delimited paths should be matched in webpack configs.Please mention other relevant information.
The text was updated successfully, but these errors were encountered: