Skip to content
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

Compilation asset keys (path) don't mach on Windows (Unable to locate stylesheet) #58

Open
boardend opened this issue Jun 22, 2020 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed webpack Issue specific to critters-webpack-plugin

Comments

@boardend
Copy link

On Windows 10 (CMD/PowerShell/Git Bash) the latest Critters version (1.3.5) is "Unable to locate stylesheet", but the same setup works without problems on a Unix-like system / WSL 2.

I think the problem is, that the path gets normalized in the "compilation.assets"-keys, but not in embedLinkedStylesheet. Here is the state in embedLinkedStylesheet on WSL2:

{
  outputPath: '/home/USERNAME/dev/git/PROJECT-ui/PROJECT/app/PROJECT-app-PROJECT2-dev/dist',
  normalizedPath: 'css/chunk-vendors.3a56f9b8.css',
  filename: '/home/USERNAME/dev/git/PROJECT-ui/PROJECT/app/PROJECT-app-PROJECT2-dev/dist/css/chunk-vendors.3a56f9b8.css',
  relativePath: 'css/chunk-vendors.3a56f9b8.css',
  compilationAssetKeys: [
    'css/chunk-vendors.3a56f9b8.css',
    [...60 lines omitted...]
 ]
}

And the same commit, but with a clone on Windows in PowerShell:

{
  outputPath: 'C:\\dev\\git\\PROJECT-ui\\PROJECT\\app\\PROJECT-app-PROJECT2-dev\\dist',
  normalizedPath: 'css/chunk-vendors.3a56f9b8.css',
  filename: 'C:\\dev\\git\\PROJECT-ui\\PROJECT\\app\\PROJECT-app-PROJECT2-dev\\dist\\css\\chunk-vendors.3a56f9b8.css',
  relativePath: 'css\\chunk-vendors.3a56f9b8.css',
  compilationAssetKeys: [
    'css/chunk-vendors.3a56f9b8.css',
    [...60 lines omitted...]
 ]
}

so compilation.assets[relativePath] won't match, which will produce the following error:

‼ 「Critters」: Unable to locate stylesheet: css\chunk-vendors.3a56f9b8.css
@developit
Copy link
Collaborator

developit commented Aug 23, 2020

Ahh, good catch. We can definitely get this fixed, I'm now working part-time on a windows machine so its easier to test. It looks like most of the path manipulation in that function needs to be normalized - likely to forward slashes, since they're URLs, but right now it's a mix.

@developit developit added good first issue Good for newcomers help wanted Extra attention is needed bug Something isn't working webpack Issue specific to critters-webpack-plugin labels Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed webpack Issue specific to critters-webpack-plugin
Projects
None yet
Development

No branches or pull requests

2 participants