excubo-ag / WebCompiler

Apache License 2.0
148 stars 29 forks source link

Ignore in config is ignored #88

Closed lonix1 closed 6 months ago

lonix1 commented 8 months ago

Found another issue, maybe. Sorry for bombarding your repo with so many issues, I'm a new user.


webcompiler.json includes:

"CompilerSettings": {
  "Ignore": [ "**/_*.*", "wwwroot/lib/**/*", "Pages/Isolated.scss" ],
  },

Pages/Isolated.scss:

// these do not exist in /Pages/
// but will exist in /obj/Debug/net7.0/scopedcss/
// they are placed there automatically by the runtime for "css isolation"
@use './Index.cshtml.rz.scp.css';
@use './Edit.cshtml.rz.scp.css';
@use './Create.cshtml.rz.scp.css';

MyProject.csproj includes:

<!-- copies file to correct directory then runs webcompiler on it -->
<Target Name="CompileIsolatedCss" AfterTargets="AfterBuild">
  <Copy SourceFiles="Pages/Isolated.scss" DestinationFolder="obj/$(Configuration)/$(TargetFramework)/scopedcss/Pages/" />
  <Exec Command="dotnet webcompiler --config webcompiler.json obj/$(Configuration)/$(TargetFramework)/scopedcss/Pages/Isolated.scss" StandardOutputImportance="high" />
</Target>

Error on build:

EXEC : error : Can't find stylesheet to import. [/home/username/project/MyProject.csproj]
    at root stylesheet (Pages/Isolated.scss:6:1) -> @use './Index.cshtml.rz.scp.css';
 -- in file /home/username/project/MyProject/Pages/Isolated.scss L6:1
/home/username/project/MyProject.csproj(18,5): error MSB3073: The command "dotnet webcompiler --config webcompiler.json --recursive Pages" exited with code 1.

Unless I'm making a mistake somewhere, I think the Ignore in the config is being ignored (excuse the pun! :smile:).

lonix1 commented 8 months ago

BTW I have a workaround so this is not really an issue for me. I just thought you might like to know there's a bug (I think... maybe I'm wrong).

stefanloerwald commented 6 months ago

Sorry for the long wait for a response on this.

As far as I can tell, you're using the ignore, and then passing an individual file to compile. The ignore function was only applied to recursive discovery of files (i.e., when you pass in a folder).

I see how this causes issues in toolchains that enumerate files, including those that are supposed to be ignored. A fix is on its way.