johan-v-r / LibSassBuilder

Sass builder for .NET projects
MIT License
98 stars 14 forks source link

CSS generation issues #19

Closed cpboyd closed 3 years ago

cpboyd commented 3 years ago

I found this project after searching for a more up-to-date Sass implementation from Delegate.SassBuilder.

I'm using CSS isolation in Blazor, per: https://docs.microsoft.com/en-us/aspnet/core/blazor/components/css-isolation?view=aspnetcore-5.0#css-preprocessor-support

Is there a way to ensure that the Blazor build waits on the Sass compilation to complete first? It seems that the Blazor build continues without waiting for the CSS files to be generated first (and thus missing any changes in that build).

Additionally, CSS isn't re-generated (possibly due to the hash check) when CSS files are manually deleted.

johan-v-r commented 3 years ago

Hi @cpboyd

I'm also using this with CSS isolation in Blazor, and it should wait for the Sass compilation. How are you building your solution? With VS, or CLI dotnet build? Do you perhaps have steps to replicate your issue?

Thnslj commented 3 years ago

I am seeing the same issue. I have to run a dotnet build first. and then a dotnet publish else the dotnet publish command wont find the compiled css files.

Repro steps:

johan-v-r commented 3 years ago

Thanks @Thnslj

I'm following your steps with the below commands:

dotnet new blazorwasm
dotnet add package LibSassBuilder
echo "body { background-color: blue; }" > wwwroot/test.scss
dotnet publish -o output

On both Windows & Ubuntu this works and I can see Sass compile files as part of my dotnet publish output:

jvr@JvR-XPS:~/sourcecode/cssgenerationissues$ dotnet publish -o output
Microsoft (R) Build Engine version 16.8.0+126527ff1 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
  Sass compile files
  Sass files compiled
  cssgenerationissues -> /home/jvr/sourcecode/cssgenerationissues/bin/Debug/net5.0/cssgenerationissues.dll
  cssgenerationissues (Blazor output) -> /home/jvr/sourcecode/cssgenerationissues/bin/Debug/net5.0/wwwroot
  Optimizing assemblies for size, which may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
  Compressing Blazor WebAssembly publish artifacts. This may take a while...
  cssgenerationissues -> /home/jvr/sourcecode/cssgenerationissues/output/
jvr@JvR-XPS:~/sourcecode/cssgenerationissues$ ls output/wwwroot/
_framework                      cssgenerationissues.styles.css.br  favicon.ico.br  index.html.br  test.css
css                             cssgenerationissues.styles.css.gz  favicon.ico.gz  index.html.gz  test.css.br
cssgenerationissues.styles.css  favicon.ico                        index.html      sample-data    test.css.gz
jvr@JvR-XPS:~/sourcecode/cssgenerationissues$ cat output/wwwroot/test.css
body{background-color:blue}
jvr@JvR-XPS:~/sourcecode/cssgenerationissues$

Which platform & versions are you using? Maybe try send me your console output if possible?

cpboyd commented 3 years ago

I was running on Windows 10 with the Visual Studio "run" button. At the moment, I'm not able to use the dotnet CLI to add packages due to 401 errors from private sources (apparently resolving in VS doesn't necessarily add them for the CLI).

I do recall seeing it actually run and update the individual file... but the merged test.styles.css or whatever wouldn't contain the updates (perhaps due to some parallel build process).

johan-v-r commented 3 years ago

Were you editing the file while the app was running? Can you share your build output? Also maybe try disabling any extra VS extensions you might have to see if that makes a difference?

When I edit the file between VS runs, my output looks like this:

image

I'm really struggling to replicate this. Last resort if you can maybe share a github repo to reproduce your situation?

cpboyd commented 3 years ago

After setting up the project from scratch, I wasn't able to reproduce so I'll close this for now.

Thanks for looking into it.