Closed Liero closed 2 years ago
Hi @Liero,
I understand what you want the behavior to be, but to me, both approaches seem valid to me and it would be a breaking change. Most tools, including compilers, actually behave differently depending on where they are executed.
Would you consider a solution where you supply another command line parameter to change the behavior? For example something like -f src\myproject\files.conf --relative-to-files-json-path
?
Would you consider a solution where you supply another command line parameter?
sure, but no need to hurry. I've found another way to deal with it. Would you mind leaving this issue opened for a while?
Would you mind leaving this issue opened for a while?
No problem at all!
If you don't mind: could you maybe think of what that command line parameter should be named? --relative-to-files-json-path
feels too long, and doesn't have a logical one-character shorthand (-r
is already taken for --recursive
). Can you think of something better?
Thanks Stefan
What about a first line comment in the files.config?
//root: ./
resp //root: currentdirectory
Anyway, I was thinking that maybe there will be a need for extended configuration of the files in the future. Something similar to the original webcompiler, where each file can be configured separately.
Personally I would like to configure list of the files in the webcompilerconfig.json, but that's a different story.
Although I'm skeptical, whether anybody would ever need the filepaths to be relative to anything else than the config file. Can you imagine, that files in .csproj would not be relative to the csproj? Or files in tsconfig would not be relative to tsconfig, or files in angular.json would not be relative to angular.json?
Only files passed as command line arguments should be relative to current directory.
I personally don't use the --files
option at all, so I don't have strong preferences.
I find handling each file separately incredibly tedious, so that's why I didn't go for that route. I always wanted a recursive mode and/or wildcard support, and with the existing tool (adding it through command line), this works just fine.
What's your use case to configure files individually?
Yeah, why don't you add wildcard support to the files.config? :D That was my second feature request, but one step at a time. I could create a PR for it, btw.
My problem was, that I had some files, like common.scss, that I used to import to site.scss. I don't want to compile common.scss separately.
I'm not going to add wildcard support in the files
option, because I don't use it at all ;-) But I'm always willing to review PRs.
Compiling common.scss might be useless, but is it harmful? I personally would probably just ignore its compilation. Or I'd move it to a folder that I don't include in the compilation step.
Also I would like to compile pages/**
AND wwwroot/styles/**
, but not wwwroot/lib/**
Also I would like to compile
pages/**
ANDwwwroot/styles/**
, but notwwwroot/lib/**
webcompiler -r ./pages/ ./wwwroot/styles/
should work for that, right?
Editing my reply because I just found why my files.conf wasn't working.
I thought the pathing wasnt working, but I just needed to remove "" from around my file names.
Will leave this note here in case someone else has the same problem as me
The way the --files
option is implemented makes it quite clear how it'll work:
Every line in that file is interpreted as if it were a single command line parameter. In the command line, you need quotation marks around file names containing spaces, because otherwise the spaces separate the file name into multiple arguments, which individually will not be found. When reading from file, the entire line is interpreted as one path.
I think the file paths in files.conf should be relative to the config file, because it should build regardless of what current directory is.
For example, only one of following options will currently build, depending on paths in files.conf
C:\mysolution> dotnet webcompiler -f src\myproject\files.conf
requires paths in files.conf to start with src\myproject, which is weird
C:\mysolution\src\myproject> dotnet webcompiler -f files.conf
will build if paths are relative to files.conf