├── .github
└── workflows
│ ├── codeql-analysis.yml
│ ├── dotnet-core.yml
│ ├── publish-nuget.yml
│ └── publish-tool.yml
├── .gitignore
├── LICENSE
├── README.md
├── package.ps1
├── package
├── LibSassBuilder.csproj
├── LibSassBuilder.nuspec
├── build
│ ├── DesignTime
│ │ ├── LibSassBuilder.DesignTime.targets
│ │ └── Rules
│ │ │ ├── ProjectItemsSchema.xaml
│ │ │ └── SassFileType.xaml
│ ├── LibSassBuilder.props
│ └── LibSassBuilder.targets
└── sass.png
└── src
├── LibSassBuilder.DirectoryTests
├── DirectoryTests.cs
├── LibSassBuilder.DirectoryTests.csproj
├── foo
│ └── bar.scss
└── logs
│ ├── bin
│ └── bin-file.scss
│ ├── dialogs
│ └── dialog-file.scss
│ └── logs-file.scss
├── LibSassBuilder.ExcludeTests
├── ExcludeTests.cs
├── LibSassBuilder.ExcludeTests.csproj
├── bar
│ └── bar.scss
├── foo
│ └── foo.scss
└── test.scss
├── LibSassBuilder.Tests
├── FileTests.cs
├── LibSassBuilder.Tests.csproj
└── test-files
│ ├── _ignored.scss
│ ├── bin
│ └── bin-file.scss
│ ├── logs
│ └── logs-file.scss
│ ├── node_modules
│ └── app.scss
│ ├── obj
│ └── obj-file.scss
│ ├── test-indented-format.sass
│ └── test-new-format.scss
├── LibSassBuilder.sln
└── LibSassBuilder
├── DirectoryOptions.cs
├── FilesOptions.cs
├── GenericOptions.cs
├── LibSassBuilder.csproj
├── Program.cs
└── Properties
└── launchSettings.json
/.github/workflows/codeql-analysis.yml:
--------------------------------------------------------------------------------
1 | # For most projects, this workflow file will not need changing; you simply need
2 | # to commit it to your repository.
3 | #
4 | # You may wish to alter this file to override the set of languages analyzed,
5 | # or to provide custom queries or build logic.
6 | #
7 | # ******** NOTE ********
8 | # We have attempted to detect the languages in your repository. Please check
9 | # the `language` matrix defined below to confirm you have the correct set of
10 | # supported CodeQL languages.
11 | #
12 | name: "CodeQL"
13 |
14 | on:
15 | push:
16 | branches: [ main ]
17 | pull_request:
18 | # The branches below must be a subset of the branches above
19 | branches: [ main ]
20 | schedule:
21 | - cron: '23 9 * * 1'
22 |
23 | jobs:
24 | analyze:
25 | name: Analyze
26 | runs-on: ubuntu-latest
27 | permissions:
28 | actions: read
29 | contents: read
30 | security-events: write
31 |
32 | strategy:
33 | fail-fast: false
34 | matrix:
35 | language: [ 'csharp' ]
36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
37 | # Learn more:
38 | # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
39 |
40 | steps:
41 | - name: Setup .NET
42 | uses: actions/setup-dotnet@v1
43 | with:
44 | dotnet-version: '7.0'
45 |
46 | - name: Checkout repository
47 | uses: actions/checkout@v2
48 |
49 | # Initializes the CodeQL tools for scanning.
50 | - name: Initialize CodeQL
51 | uses: github/codeql-action/init@v2
52 | with:
53 | languages: ${{ matrix.language }}
54 | # If you wish to specify custom queries, you can do so here or in a config file.
55 | # By default, queries listed here will override any specified in a config file.
56 | # Prefix the list here with "+" to use these queries and those in the config file.
57 | # queries: ./path/to/local/query, your-org/your-repo/queries@main
58 |
59 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
60 | # If this step fails, then you should remove it and run the build manually (see below)
61 | - name: Autobuild
62 | uses: github/codeql-action/autobuild@v2
63 |
64 | # ℹ️ Command-line programs to run using the OS shell.
65 | # 📚 https://git.io/JvXDl
66 |
67 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
68 | # and modify them (or add more) to build your code if your project
69 | # uses a compiled language
70 |
71 | #- run: |
72 | # make bootstrap
73 | # make release
74 |
75 | - name: Perform CodeQL Analysis
76 | uses: github/codeql-action/analyze@v2
77 |
--------------------------------------------------------------------------------
/.github/workflows/dotnet-core.yml:
--------------------------------------------------------------------------------
1 | name: Build
2 |
3 | on:
4 | workflow_dispatch:
5 | push:
6 | branches: [ main ]
7 | paths:
8 | - 'src/**'
9 | pull_request:
10 | branches: [ main ]
11 | paths:
12 | - 'src/**'
13 |
14 | jobs:
15 | build:
16 |
17 | runs-on: ${{ matrix.os }}
18 | strategy:
19 | max-parallel: 1
20 | matrix:
21 | os: [windows-latest, ubuntu-latest, macos-latest]
22 |
23 | defaults:
24 | run:
25 | working-directory: ./src
26 |
27 | steps:
28 | - uses: actions/checkout@v2
29 | - name: Setup .NET
30 | uses: actions/setup-dotnet@v1
31 | with:
32 | dotnet-version: '7.x'
33 | - name: Install dependencies
34 | run: dotnet restore
35 | - name: Build LibSassBuilder
36 | run: dotnet build ./LibSassBuilder --no-restore
37 | - name: Build LibSassBuilder.DirectoryTests
38 | run: dotnet build ./LibSassBuilder.DirectoryTests --no-restore
39 | - name: Build LibSassBuilder.ExcludeTests
40 | run: dotnet build ./LibSassBuilder.ExcludeTests --no-restore
41 | - name: Build LibSassBuilder.Tests
42 | run: dotnet build ./LibSassBuilder.Tests --no-restore
43 | - name: Test
44 | run: dotnet test --no-restore --verbosity normal
45 |
--------------------------------------------------------------------------------
/.github/workflows/publish-nuget.yml:
--------------------------------------------------------------------------------
1 | name: Publish
2 |
3 | on:
4 | workflow_dispatch:
5 | push:
6 | branches: [ main ]
7 | paths:
8 | - 'package/LibSassBuilder.nuspec'
9 |
10 | jobs:
11 | build:
12 |
13 | runs-on: windows-latest
14 | defaults:
15 | run:
16 | working-directory: ./src
17 |
18 | steps:
19 | - uses: actions/checkout@v2
20 | - name: Setup .NET Core
21 | uses: actions/setup-dotnet@v1
22 | with:
23 | dotnet-version: '7.x'
24 | - name: Install dependencies
25 | run: dotnet restore
26 | - name: Build
27 | run: dotnet build --configuration Release --no-restore
28 | - name: Test
29 | run: dotnet test --no-restore --verbosity normal
30 | - name: dotnet publish
31 | run: dotnet publish -c Release -o ..\package\tool\ .\LibSassBuilder\
32 |
33 | - name: Setup NuGet.exe
34 | # You may pin to the exact commit or the version.
35 | # uses: NuGet/setup-nuget@04b0c2b8d1b97922f67eca497d7cf0bf17b8ffe1
36 | uses: NuGet/setup-nuget@v1.0.5
37 | with:
38 | # NuGet version to install. Can be `latest`, `preview`, a concrete version like `5.3.1`, or a semver range specifier like `5.x`.
39 | nuget-version: latest # optional, default is latest
40 | # NuGet API Key to configure.
41 | #nuget-api-key: # optional
42 | # Source to scope the NuGet API Key to.
43 | #nuget-api-key-source: # optional
44 |
45 | - name: NuGet pack
46 | run: nuget pack '../package/LibSassBuilder.nuspec' -OutputDirectory 'nuget-package'
47 |
48 | - uses: actions/upload-artifact@v2.2.1
49 | with:
50 | name: nuget-package
51 | path: './src/nuget-package/*'
52 |
--------------------------------------------------------------------------------
/.github/workflows/publish-tool.yml:
--------------------------------------------------------------------------------
1 | name: Publish Tool
2 |
3 | on:
4 | workflow_dispatch:
5 | push:
6 | branches: [ main ]
7 | paths:
8 | - 'src/LibSassBuilder/**'
9 |
10 | jobs:
11 | build:
12 |
13 | runs-on: windows-latest
14 | defaults:
15 | run:
16 | working-directory: ./src
17 |
18 | steps:
19 | - uses: actions/checkout@v2
20 | - name: Setup .NET Core
21 | uses: actions/setup-dotnet@v1
22 | with:
23 | dotnet-version: '7.x'
24 | - name: Install dependencies
25 | run: dotnet restore
26 | - name: Build
27 | run: dotnet build --configuration Release --no-restore
28 | - name: Test
29 | run: dotnet test --no-restore --verbosity normal
30 | - name: dotnet pack
31 | run: dotnet pack LibSassBuilder -o 'nuget-tool-package'
32 |
33 | - uses: actions/upload-artifact@v2.2.1
34 | with:
35 | name: nuget-tool-package
36 | path: './src/nuget-tool-package/*'
37 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Aa][Rr][Mm]/
27 | [Aa][Rr][Mm]64/
28 | bld/
29 | [Bb]in/
30 | [Oo]bj/
31 | [Ll]og/
32 | [Ll]ogs/
33 |
34 | package/tool/
35 |
36 | # Visual Studio 2015/2017 cache/options directory
37 | .vs/
38 | # Uncomment if you have tasks that create the project's static files in wwwroot
39 | #wwwroot/
40 |
41 | # Visual Studio 2017 auto generated files
42 | Generated\ Files/
43 |
44 | # MSTest test Results
45 | [Tt]est[Rr]esult*/
46 | [Bb]uild[Ll]og.*
47 |
48 | # NUnit
49 | *.VisualState.xml
50 | TestResult.xml
51 | nunit-*.xml
52 |
53 | # Build Results of an ATL Project
54 | [Dd]ebugPS/
55 | [Rr]eleasePS/
56 | dlldata.c
57 |
58 | # Benchmark Results
59 | BenchmarkDotNet.Artifacts/
60 |
61 | # .NET Core
62 | project.lock.json
63 | project.fragment.lock.json
64 | artifacts/
65 |
66 | # StyleCop
67 | StyleCopReport.xml
68 |
69 | # Files built by Visual Studio
70 | *_i.c
71 | *_p.c
72 | *_h.h
73 | *.ilk
74 | *.meta
75 | *.obj
76 | *.iobj
77 | *.pch
78 | *.pdb
79 | *.ipdb
80 | *.pgc
81 | *.pgd
82 | *.rsp
83 | *.sbr
84 | *.tlb
85 | *.tli
86 | *.tlh
87 | *.tmp
88 | *.tmp_proj
89 | *_wpftmp.csproj
90 | *.log
91 | *.vspscc
92 | *.vssscc
93 | .builds
94 | *.pidb
95 | *.svclog
96 | *.scc
97 |
98 | # Chutzpah Test files
99 | _Chutzpah*
100 |
101 | # Visual C++ cache files
102 | ipch/
103 | *.aps
104 | *.ncb
105 | *.opendb
106 | *.opensdf
107 | *.sdf
108 | *.cachefile
109 | *.VC.db
110 | *.VC.VC.opendb
111 |
112 | # Visual Studio profiler
113 | *.psess
114 | *.vsp
115 | *.vspx
116 | *.sap
117 |
118 | # Visual Studio Trace Files
119 | *.e2e
120 |
121 | # TFS 2012 Local Workspace
122 | $tf/
123 |
124 | # Guidance Automation Toolkit
125 | *.gpState
126 |
127 | # ReSharper is a .NET coding add-in
128 | _ReSharper*/
129 | *.[Rr]e[Ss]harper
130 | *.DotSettings.user
131 |
132 | # TeamCity is a build add-in
133 | _TeamCity*
134 |
135 | # DotCover is a Code Coverage Tool
136 | *.dotCover
137 |
138 | # AxoCover is a Code Coverage Tool
139 | .axoCover/*
140 | !.axoCover/settings.json
141 |
142 | # Visual Studio code coverage results
143 | *.coverage
144 | *.coveragexml
145 |
146 | # NCrunch
147 | _NCrunch_*
148 | .*crunch*.local.xml
149 | nCrunchTemp_*
150 |
151 | # MightyMoose
152 | *.mm.*
153 | AutoTest.Net/
154 |
155 | # Web workbench (sass)
156 | .sass-cache/
157 |
158 | # Installshield output folder
159 | [Ee]xpress/
160 |
161 | # DocProject is a documentation generator add-in
162 | DocProject/buildhelp/
163 | DocProject/Help/*.HxT
164 | DocProject/Help/*.HxC
165 | DocProject/Help/*.hhc
166 | DocProject/Help/*.hhk
167 | DocProject/Help/*.hhp
168 | DocProject/Help/Html2
169 | DocProject/Help/html
170 |
171 | # Click-Once directory
172 | publish/
173 |
174 | # Publish Web Output
175 | *.[Pp]ublish.xml
176 | *.azurePubxml
177 | # Note: Comment the next line if you want to checkin your web deploy settings,
178 | # but database connection strings (with potential passwords) will be unencrypted
179 | *.pubxml
180 | *.publishproj
181 |
182 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
183 | # checkin your Azure Web App publish settings, but sensitive information contained
184 | # in these scripts will be unencrypted
185 | PublishScripts/
186 |
187 | # NuGet Packages
188 | *.nupkg
189 | # NuGet Symbol Packages
190 | *.snupkg
191 | # The packages folder can be ignored because of Package Restore
192 | **/[Pp]ackages/*
193 | # except build/, which is used as an MSBuild target.
194 | !**/[Pp]ackages/build/
195 | # Uncomment if necessary however generally it will be regenerated when needed
196 | #!**/[Pp]ackages/repositories.config
197 | # NuGet v3's project.json files produces more ignorable files
198 | *.nuget.props
199 | *.nuget.targets
200 |
201 | # Microsoft Azure Build Output
202 | csx/
203 | *.build.csdef
204 |
205 | # Microsoft Azure Emulator
206 | ecf/
207 | rcf/
208 |
209 | # Windows Store app package directories and files
210 | AppPackages/
211 | BundleArtifacts/
212 | Package.StoreAssociation.xml
213 | _pkginfo.txt
214 | *.appx
215 | *.appxbundle
216 | *.appxupload
217 |
218 | # Visual Studio cache files
219 | # files ending in .cache can be ignored
220 | *.[Cc]ache
221 | # but keep track of directories ending in .cache
222 | !?*.[Cc]ache/
223 |
224 | # Others
225 | ClientBin/
226 | ~$*
227 | *~
228 | *.dbmdl
229 | *.dbproj.schemaview
230 | *.jfm
231 | *.pfx
232 | *.publishsettings
233 | orleans.codegen.cs
234 |
235 | # Including strong name files can present a security risk
236 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
237 | #*.snk
238 |
239 | # Since there are multiple workflows, uncomment next line to ignore bower_components
240 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
241 | #bower_components/
242 |
243 | # RIA/Silverlight projects
244 | Generated_Code/
245 |
246 | # Backup & report files from converting an old project file
247 | # to a newer Visual Studio version. Backup files are not needed,
248 | # because we have git ;-)
249 | _UpgradeReport_Files/
250 | Backup*/
251 | UpgradeLog*.XML
252 | UpgradeLog*.htm
253 | ServiceFabricBackup/
254 | *.rptproj.bak
255 |
256 | # SQL Server files
257 | *.mdf
258 | *.ldf
259 | *.ndf
260 |
261 | # Business Intelligence projects
262 | *.rdl.data
263 | *.bim.layout
264 | *.bim_*.settings
265 | *.rptproj.rsuser
266 | *- [Bb]ackup.rdl
267 | *- [Bb]ackup ([0-9]).rdl
268 | *- [Bb]ackup ([0-9][0-9]).rdl
269 |
270 | # Microsoft Fakes
271 | FakesAssemblies/
272 |
273 | # GhostDoc plugin setting file
274 | *.GhostDoc.xml
275 |
276 | # Node.js Tools for Visual Studio
277 | .ntvs_analysis.dat
278 | node_modules/
279 |
280 | # Visual Studio 6 build log
281 | *.plg
282 |
283 | # Visual Studio 6 workspace options file
284 | *.opt
285 |
286 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
287 | *.vbw
288 |
289 | # Visual Studio LightSwitch build output
290 | **/*.HTMLClient/GeneratedArtifacts
291 | **/*.DesktopClient/GeneratedArtifacts
292 | **/*.DesktopClient/ModelManifest.xml
293 | **/*.Server/GeneratedArtifacts
294 | **/*.Server/ModelManifest.xml
295 | _Pvt_Extensions
296 |
297 | # Paket dependency manager
298 | .paket/paket.exe
299 | paket-files/
300 |
301 | # FAKE - F# Make
302 | .fake/
303 |
304 | # CodeRush personal settings
305 | .cr/personal
306 |
307 | # Python Tools for Visual Studio (PTVS)
308 | __pycache__/
309 | *.pyc
310 |
311 | # Cake - Uncomment if you are using it
312 | # tools/**
313 | # !tools/packages.config
314 |
315 | # Tabs Studio
316 | *.tss
317 |
318 | # Telerik's JustMock configuration file
319 | *.jmconfig
320 |
321 | # BizTalk build output
322 | *.btp.cs
323 | *.btm.cs
324 | *.odx.cs
325 | *.xsd.cs
326 |
327 | # OpenCover UI analysis results
328 | OpenCover/
329 |
330 | # Azure Stream Analytics local run output
331 | ASALocalRun/
332 |
333 | # MSBuild Binary and Structured Log
334 | *.binlog
335 |
336 | # NVidia Nsight GPU debugger configuration file
337 | *.nvuser
338 |
339 | # MFractors (Xamarin productivity tool) working folder
340 | .mfractor/
341 |
342 | # Local History for Visual Studio
343 | .localhistory/
344 |
345 | # BeatPulse healthcheck temp database
346 | healthchecksdb
347 |
348 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
349 | MigrationBackup/
350 |
351 | # Ionide (cross platform F# VS Code tools) working folder
352 | .ionide/
353 | *.css
354 | package/tool/*
355 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 johan-v-r
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Project replaced with [DartSassBuilder](https://github.com/deanwiseman/DartSassBuilder)
2 |
3 | This project will be archived due to [LibSass](https://sass-lang.com/libsass) deprecation.
4 | > "LibSass is now deprecated—new projects should use Dart Sass instead." - https://sass-lang.com/libsass
5 |
6 | # LibSassBuilder
7 |
8 | > Inspired by [Delegate.SassBuilder](https://github.com/delegateas/Delegate.SassBuilder) and [LibSassHost](https://github.com/Taritsyn/LibSassHost)
9 |
10 | Build | NuGet Package | .NET Global Tool
11 | ---|---|---
12 |  | [](https://www.nuget.org/packages/LibSassBuilder/) | [](https://www.nuget.org/packages/LibSassBuilder-Tool/)
13 |
14 |
15 | 
16 |
17 | ## [Nuget Package](https://www.nuget.org/packages/LibSassBuilder)
18 |
19 | `LibSassBuilder` NuGet package adds a build task to compile Sass files to `.css`. It's compatible with both MSBuild (VS) and `dotnet build`.
20 |
21 | No configuration is required, it will compile the files implicitly on project build.
22 |
23 | - ### Optionally provide arguments (see _Options_ below):
24 |
25 | ```xml
26 |
27 |
28 | compressed
29 | expanded
30 |
31 | verbose
32 |
33 | High
34 |
35 | ```
36 |
37 | - ### Or take control of what files to process
38 |
39 | ```xml
40 |
41 |
42 | false
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | ```
51 |
52 | - ### Or ignore all previous options (except for ``) and determine the arguments to the tool yourself
53 |
54 | ```xml
55 |
56 |
57 | directory "$(MSBuildProjectDirectory)"
58 |
59 | High
60 |
61 | ```
62 |
63 | ___
64 | ## [.NET Global Tool](https://www.nuget.org/packages/LibSassBuilder-Tool)
65 |
66 | Install:
67 | ```
68 | dotnet tool install --global LibSassBuilder-Tool
69 | ```
70 |
71 | Use:
72 | ```
73 | lsb [optional-path] [options]
74 | lsb help
75 | lsb help directory
76 | lsb help files
77 | ```
78 |
79 | ## Generic options
80 |
81 | ```
82 | -l, --level Specify the level of output (silent, default, verbose)
83 |
84 | --outputstyle Specify the style of output (compressed, compact, nested, expanded)
85 | ```
86 |
87 | ## Directory command (default)
88 |
89 | Scans a directory recursively to generate .css files
90 |
91 | ```
92 | -e, --exclude (Default: bin obj logs node_modules) Specify explicit directories to exclude. Overrides the default.
93 |
94 | --help Display this help screen.
95 |
96 | --version Display version information.
97 |
98 | value pos. 0 Directory in which to run. Defaults to current directory.
99 | ```
100 |
101 | Example:
102 |
103 | ```
104 | lsb directory
105 | lsb directory sources/styles -e node_modules
106 | lsb directory sources/styles -e node_modules -l verbose
107 | ```
108 |
109 | Files in the following directories are excluded by default:
110 | - `bin`
111 | - `obj`
112 | - `logs`
113 | - `node_modules`
114 |
115 |
116 | ## Files command (default)
117 |
118 | Processes the files given on the commandline
119 |
120 | ```
121 | --help Display this help screen.
122 |
123 | --version Display version information.
124 |
125 | value pos. 0 File(s) to process.
126 | ```
127 |
128 | Example:
129 |
130 | ```
131 | lsb files sources/style/a.scss sources/vendor/b.scss
132 | lsb files sources/style/a.scss sources/vendor/b.scss -l verbose
133 | ```
134 | ___
135 |
136 | ## Requirements
137 |
138 | `LibSassBuilder` can be installed on any project, however the underlying build tool requires [.NET 7](https://dotnet.microsoft.com/download/dotnet/7.0) installed on the machine.
139 |
140 | > .NET 5 required with `v1.x`
141 | > .NET 6 required with `v2.x`
142 |
143 | ## Support
144 |
145 | The support is largely dependant on [LibSassHost](https://github.com/Taritsyn/LibSassHost)
146 |
147 | This tool contains the following supporting packages:
148 | - LibSassHost.Native.win-x64
149 | - LibSassHost.Native.win-x86
150 | - LibSassHost.Native.linux-x64
151 | - LibSassHost.Native.osx-x64
152 |
153 | ## Package as nuget package
154 |
155 | ```powershell
156 | ./package.ps1 -PackageDir 'C:/LocalPackages' -Version '1.4.0.1'
157 | ```
158 |
--------------------------------------------------------------------------------
/package.ps1:
--------------------------------------------------------------------------------
1 | param (
2 | [string] $PackageDir = 'out',
3 |
4 | [Parameter(Mandatory)]
5 | [string] $Version
6 | )
7 |
8 | $projectFile = "$PSScriptRoot/src/LibSassBuilder/LibSassBuilder.csproj"
9 | $nuspecProjectFile = "$PSScriptRoot/package/LibSassBuilder.csproj"
10 | $nuspecFile = "$PSScriptRoot/package/LibSassBuilder.nuspec"
11 |
12 | & dotnet build $projectFile -p:Version=$Version -c Release -o "$PSScriptRoot/package/tool"
13 | & dotnet pack $projectFile -p:Version=$Version -c Release -o $PackageDir
14 | $xml = [Xml](Get-Content -Path $nuspecFile -Raw)
15 | $xml.package.metadata.version = $Version
16 | $xml.Save($nuspecFile)
17 | & dotnet pack $nuspecProjectFile -p:Version=$Version -c Release -o $PackageDir
18 | #& dotnet pack --project $projectFile -pVersion=$Version -o $OutputDir
--------------------------------------------------------------------------------
/package/LibSassBuilder.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | LibSassBuilder.nuspec
6 |
7 | true
8 | true
9 | false
10 |
11 |
--------------------------------------------------------------------------------
/package/LibSassBuilder.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | LibSassBuilder
5 | 3.0.0
6 | LibSassBuilder
7 | Auto build task to compile .scss/.sass files to .css
8 | Johan van Rensburg
9 | Johan van Rensburg
10 | false
11 | Compile Sass files to css on project build.
12 | Sass Build LibSass SassBuilder
13 | https://github.com/johan-v-r/LibSassBuilder
14 |
15 |
16 | MIT
17 | sass.png
18 |
19 |
20 |
--------------------------------------------------------------------------------
/package/build/DesignTime/LibSassBuilder.DesignTime.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | $(MSBuildThisFileDirectory)Rules\
6 |
7 |
8 |
9 |
10 |
11 |
12 | File;BrowseObject
13 |
14 |
15 |
--------------------------------------------------------------------------------
/package/build/DesignTime/Rules/ProjectItemsSchema.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
12 |
15 |
18 |
--------------------------------------------------------------------------------
/package/build/DesignTime/Rules/SassFileType.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/package/build/LibSassBuilder.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | $(MSBuildThisFileDirectory)../tool/LibSassBuilder.dll
7 |
8 | compressed
9 |
10 | default
11 |
12 | Normal
13 |
14 | true
15 | **/bin/**;**/obj/**;**/node_modules/**;**/logs/**
16 |
17 |
21 |
22 | $(DefaultItemExcludes);**/*.scss;**/*.sass
23 |
24 |
25 |
26 |
27 |
28 |
29 | $(CustomCollectWatchItems);_LibSass_CustomCollectWatchItems
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/package/build/LibSassBuilder.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | <_LibSassHashCacheFile>$(IntermediateOutputPath)$(MSBuildProjectFile).LibSassBuilder.cache
5 | <_LibSassHashChanged>false
6 | false
7 | true
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
29 |
32 |
33 |
34 |
35 |
41 |
44 |
45 |
46 |
47 | <_LibSass_HashFiles>@(SassFile->'%(FullPath)-%(ModifiedTime)')
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
58 |
61 |
62 |
63 |
64 | <_LibSassHashChanged Condition=" '$(LibSassBuilderDependencyHash)' != '@(OldLibSassBuilderDependencyHash)' ">true
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
75 |
79 |
80 | <_SassFileList>@(SassFilesToCompile->'"%(FullPath)"', ' ')
81 | files $(_SassFileList) --outputstyle $(LibSassOutputStyle) --level $(LibSassOutputLevel)
82 |
83 |
84 |
85 |
86 |
89 |
93 |
94 |
95 |
96 |
97 |
98 |
101 |
105 |
106 |
107 |
111 |
112 |
--------------------------------------------------------------------------------
/package/sass.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/johan-v-r/LibSassBuilder/270f93f57933fc7cecd40d0099799954d3ced160/package/sass.png
--------------------------------------------------------------------------------
/src/LibSassBuilder.DirectoryTests/DirectoryTests.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using Xunit;
3 |
4 | namespace LibSassBuilder.DirectoryTests
5 | {
6 | // This project is configured to run LibSassBuilder in LibSassBuilder.DirectoryTests.csproj within ./logs directory
7 | public class DirectoryTests
8 | {
9 | private readonly string _fileDirectory;
10 |
11 | public DirectoryTests()
12 | {
13 | _fileDirectory = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName;
14 | }
15 |
16 | [Fact]
17 | public void ExplicitDirectoryTest()
18 | {
19 | var barFile = Path.Join(_fileDirectory, "foo/bar.css");
20 | var binFile = Path.Join(_fileDirectory, "logs/bin/bin-file.css");
21 | var logsFile = Path.Join(_fileDirectory, "logs/logs-file.css");
22 |
23 | Assert.False(File.Exists(barFile)); // not in ./logs directory
24 | Assert.False(File.Exists(binFile)); // inside ./logs, but excluded by default nested bin folder
25 | Assert.True(File.Exists(logsFile)); // inside ./logs
26 |
27 | File.Delete(logsFile);
28 | }
29 |
30 | [Fact]
31 | public void IncludedDirectoryTest()
32 | {
33 | var dialogsFile = Path.Join(_fileDirectory, "logs/dialogs/dialog-file.css");
34 |
35 | Assert.True(File.Exists(dialogsFile)); // inside ./logs/dialogs directory, but included as it doesn't explicitly match "logs"
36 |
37 | File.Delete(dialogsFile);
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/LibSassBuilder.DirectoryTests/LibSassBuilder.DirectoryTests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 | runtime; build; native; contentfiles; analyzers; buildtransitive
14 | all
15 |
16 |
17 | runtime; build; native; contentfiles; analyzers; buildtransitive
18 | all
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/LibSassBuilder.DirectoryTests/foo/bar.scss:
--------------------------------------------------------------------------------
1 | body {
2 | color: black;
3 | }
4 |
--------------------------------------------------------------------------------
/src/LibSassBuilder.DirectoryTests/logs/bin/bin-file.scss:
--------------------------------------------------------------------------------
1 | body {
2 | }
3 |
--------------------------------------------------------------------------------
/src/LibSassBuilder.DirectoryTests/logs/dialogs/dialog-file.scss:
--------------------------------------------------------------------------------
1 | body {
2 | }
3 |
--------------------------------------------------------------------------------
/src/LibSassBuilder.DirectoryTests/logs/logs-file.scss:
--------------------------------------------------------------------------------
1 | body {
2 | }
3 |
--------------------------------------------------------------------------------
/src/LibSassBuilder.ExcludeTests/ExcludeTests.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using Xunit;
3 |
4 | namespace LibSassBuilder.ExcludeTests
5 | {
6 | // This project is configured to run LibSassBuilder in LibSassBuilder.DirectoryTests.csproj excluding foo & bar directories
7 | public class ExcludeTests
8 | {
9 | private readonly string _fileDirectory;
10 |
11 | public ExcludeTests()
12 | {
13 | _fileDirectory = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName;
14 | }
15 |
16 | [Fact]
17 | public void ExcludeFooFilesTest()
18 | {
19 | var fooFile = Path.Join(_fileDirectory, "foo/foo.css");
20 | var barFile = Path.Join(_fileDirectory, "bar/bar.css");
21 | var testFile = Path.Join(_fileDirectory, "test.css");
22 |
23 | Assert.False(File.Exists(fooFile)); // excluded foo
24 | Assert.False(File.Exists(barFile)); // excluded bar
25 | Assert.True(File.Exists(testFile));
26 |
27 | File.Delete(testFile);
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/LibSassBuilder.ExcludeTests/LibSassBuilder.ExcludeTests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 | runtime; build; native; contentfiles; analyzers; buildtransitive
14 | all
15 |
16 |
17 | runtime; build; native; contentfiles; analyzers; buildtransitive
18 | all
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/LibSassBuilder.ExcludeTests/bar/bar.scss:
--------------------------------------------------------------------------------
1 | body {
2 | color: black;
3 | }
4 |
--------------------------------------------------------------------------------
/src/LibSassBuilder.ExcludeTests/foo/foo.scss:
--------------------------------------------------------------------------------
1 | body {
2 | color: black;
3 | }
4 |
--------------------------------------------------------------------------------
/src/LibSassBuilder.ExcludeTests/test.scss:
--------------------------------------------------------------------------------
1 | body {
2 | color: black;
3 | }
4 |
--------------------------------------------------------------------------------
/src/LibSassBuilder.Tests/FileTests.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using Xunit;
3 |
4 | namespace LibSassBuilder.Tests
5 | {
6 | // This project is configured to run LibSassBuilder in LibSassBuilder.Tests.csproj
7 | public class FileTests
8 | {
9 | private readonly string _fileDirectory;
10 |
11 | public FileTests()
12 | {
13 | _fileDirectory = Path.Join(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName, "test-files");
14 | }
15 |
16 | [Theory]
17 | [InlineData("test-new-format.css")]
18 | [InlineData("test-indented-format.css")]
19 | public void FileExistsTest(string cssFileName)
20 | {
21 | var cssFilePath = Path.Join(_fileDirectory, cssFileName);
22 |
23 | Assert.True(File.Exists(cssFilePath));
24 |
25 | File.Delete(cssFilePath);
26 | }
27 |
28 | [Theory]
29 | [InlineData("", "_ignored.css")]
30 | [InlineData("bin", "bin-file.css")]
31 | [InlineData("logs", "logs-file.css")]
32 | [InlineData("node_modules", "app.css")]
33 | [InlineData("obj", "obj-file.css")]
34 | public void ExcludedFilesTest(string subFolder, string cssFileName)
35 | {
36 | var cssFilePath = Path.Join(_fileDirectory, subFolder, cssFileName);
37 |
38 | Assert.False(File.Exists(cssFilePath));
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/LibSassBuilder.Tests/LibSassBuilder.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 | runtime; build; native; contentfiles; analyzers; buildtransitive
14 | all
15 |
16 |
17 | runtime; build; native; contentfiles; analyzers; buildtransitive
18 | all
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/LibSassBuilder.Tests/test-files/_ignored.scss:
--------------------------------------------------------------------------------
1 | body {
2 | }
3 |
--------------------------------------------------------------------------------
/src/LibSassBuilder.Tests/test-files/bin/bin-file.scss:
--------------------------------------------------------------------------------
1 | body {
2 | }
3 |
--------------------------------------------------------------------------------
/src/LibSassBuilder.Tests/test-files/logs/logs-file.scss:
--------------------------------------------------------------------------------
1 | body {
2 | }
3 |
--------------------------------------------------------------------------------
/src/LibSassBuilder.Tests/test-files/node_modules/app.scss:
--------------------------------------------------------------------------------
1 | body {
2 | }
3 |
--------------------------------------------------------------------------------
/src/LibSassBuilder.Tests/test-files/obj/obj-file.scss:
--------------------------------------------------------------------------------
1 | body {
2 | }
3 |
--------------------------------------------------------------------------------
/src/LibSassBuilder.Tests/test-files/test-indented-format.sass:
--------------------------------------------------------------------------------
1 | body
2 | color: black
--------------------------------------------------------------------------------
/src/LibSassBuilder.Tests/test-files/test-new-format.scss:
--------------------------------------------------------------------------------
1 | body {
2 | color: black;
3 | }
4 |
--------------------------------------------------------------------------------
/src/LibSassBuilder.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30709.132
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibSassBuilder", "LibSassBuilder\LibSassBuilder.csproj", "{0DB56568-9B61-47C7-9B3A-74AD4B3EEC9A}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibSassBuilder.Tests", "LibSassBuilder.Tests\LibSassBuilder.Tests.csproj", "{6401A537-4B7B-42F8-A515-67240B4C0F0C}"
9 | ProjectSection(ProjectDependencies) = postProject
10 | {0DB56568-9B61-47C7-9B3A-74AD4B3EEC9A} = {0DB56568-9B61-47C7-9B3A-74AD4B3EEC9A}
11 | EndProjectSection
12 | EndProject
13 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibSassBuilder.DirectoryTests", "LibSassBuilder.DirectoryTests\LibSassBuilder.DirectoryTests.csproj", "{F51D398C-D259-4539-8EE4-E037B213F3C6}"
14 | ProjectSection(ProjectDependencies) = postProject
15 | {0DB56568-9B61-47C7-9B3A-74AD4B3EEC9A} = {0DB56568-9B61-47C7-9B3A-74AD4B3EEC9A}
16 | EndProjectSection
17 | EndProject
18 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibSassBuilder.ExcludeTests", "LibSassBuilder.ExcludeTests\LibSassBuilder.ExcludeTests.csproj", "{16069D4E-516D-4DE6-A0E7-D2429E1F7485}"
19 | ProjectSection(ProjectDependencies) = postProject
20 | {0DB56568-9B61-47C7-9B3A-74AD4B3EEC9A} = {0DB56568-9B61-47C7-9B3A-74AD4B3EEC9A}
21 | EndProjectSection
22 | EndProject
23 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9D63AEC3-CC7D-43C2-9501-5A00E9767C7D}"
24 | ProjectSection(SolutionItems) = preProject
25 | ..\package\build\LibSassBuilder.props = ..\package\build\LibSassBuilder.props
26 | ..\package\build\LibSassBuilder.targets = ..\package\build\LibSassBuilder.targets
27 | ..\README.md = ..\README.md
28 | EndProjectSection
29 | EndProject
30 | Global
31 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
32 | Debug|Any CPU = Debug|Any CPU
33 | Release|Any CPU = Release|Any CPU
34 | EndGlobalSection
35 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
36 | {0DB56568-9B61-47C7-9B3A-74AD4B3EEC9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37 | {0DB56568-9B61-47C7-9B3A-74AD4B3EEC9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
38 | {0DB56568-9B61-47C7-9B3A-74AD4B3EEC9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
39 | {0DB56568-9B61-47C7-9B3A-74AD4B3EEC9A}.Release|Any CPU.Build.0 = Release|Any CPU
40 | {6401A537-4B7B-42F8-A515-67240B4C0F0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
41 | {6401A537-4B7B-42F8-A515-67240B4C0F0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
42 | {6401A537-4B7B-42F8-A515-67240B4C0F0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
43 | {6401A537-4B7B-42F8-A515-67240B4C0F0C}.Release|Any CPU.Build.0 = Release|Any CPU
44 | {F51D398C-D259-4539-8EE4-E037B213F3C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
45 | {F51D398C-D259-4539-8EE4-E037B213F3C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
46 | {F51D398C-D259-4539-8EE4-E037B213F3C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
47 | {F51D398C-D259-4539-8EE4-E037B213F3C6}.Release|Any CPU.Build.0 = Release|Any CPU
48 | {16069D4E-516D-4DE6-A0E7-D2429E1F7485}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
49 | {16069D4E-516D-4DE6-A0E7-D2429E1F7485}.Debug|Any CPU.Build.0 = Debug|Any CPU
50 | {16069D4E-516D-4DE6-A0E7-D2429E1F7485}.Release|Any CPU.ActiveCfg = Release|Any CPU
51 | {16069D4E-516D-4DE6-A0E7-D2429E1F7485}.Release|Any CPU.Build.0 = Release|Any CPU
52 | EndGlobalSection
53 | GlobalSection(SolutionProperties) = preSolution
54 | HideSolutionNode = FALSE
55 | EndGlobalSection
56 | GlobalSection(ExtensibilityGlobals) = postSolution
57 | SolutionGuid = {49B21107-8AFF-4E34-BB62-73EAB3FAC6A5}
58 | EndGlobalSection
59 | EndGlobal
60 |
--------------------------------------------------------------------------------
/src/LibSassBuilder/DirectoryOptions.cs:
--------------------------------------------------------------------------------
1 | using CommandLine;
2 | using System.Collections.Generic;
3 |
4 | namespace LibSassBuilder
5 | {
6 | [Verb("directory", isDefault: true)]
7 | public class DirectoryOptions : GenericOptions
8 | {
9 | [Value(0, Required = false, HelpText = "Directory in which to run. Defaults to current directory.")]
10 | public string Directory { get; set; } = System.IO.Directory.GetCurrentDirectory();
11 |
12 | [Option('e', "exclude", Required = false, HelpText = "Specify explicit directories to exclude. Overrides the default.", Default = new[] { "bin", "obj", "logs", "node_modules" })]
13 | public IEnumerable ExcludedDirectories { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/LibSassBuilder/FilesOptions.cs:
--------------------------------------------------------------------------------
1 | using CommandLine;
2 | using System.Collections.Generic;
3 |
4 | namespace LibSassBuilder
5 | {
6 | [Verb("files")]
7 | public class FilesOptions : GenericOptions
8 | {
9 | [Value(0, Required = true, HelpText = "File(s) to process")]
10 | public IEnumerable Files { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/LibSassBuilder/GenericOptions.cs:
--------------------------------------------------------------------------------
1 | using CommandLine;
2 | using LibSassHost;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace LibSassBuilder
10 | {
11 | public abstract class GenericOptions
12 | {
13 | [Option('l', "level", Required = false, HelpText = "Specify the level of output (silent, default, verbose)")]
14 | public OutputLevel OutputLevel { get; set; } = OutputLevel.Default;
15 |
16 | public CompilationOptions SassCompilationOptions { get; } = new CompilationOptions()
17 | {
18 | OutputStyle = OutputStyle.Compressed
19 | };
20 |
21 | [Option("outputstyle", Required = false, HelpText = "Specify the style of output (compressed, compact, nested, expanded)")]
22 | public OutputStyle OutputStyle
23 | {
24 | get
25 | {
26 | return SassCompilationOptions.OutputStyle;
27 | }
28 | set
29 | {
30 | SassCompilationOptions.OutputStyle = value;
31 | }
32 | }
33 | }
34 |
35 | public enum OutputLevel
36 | {
37 | Silent,
38 | Default,
39 | Verbose
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/LibSassBuilder/LibSassBuilder.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | 3.0.0
6 | net7.0
7 | true
8 | LibSassBuilder-Tool
9 | lsb
10 | Johan van Rensburg
11 | Compile Sass files to css from CLI. Install globally with `dotnet tool install -g LibSassBuilder-Tool`
12 | https://github.com/johan-v-r/LibSassBuilder
13 | https://github.com/johan-v-r/LibSassBuilder.git
14 | git
15 | Sass Build LibSass SassBuilder
16 | MIT
17 | sass.png
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | True
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/src/LibSassBuilder/Program.cs:
--------------------------------------------------------------------------------
1 | using CommandLine;
2 | using LibSassHost;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Threading.Tasks;
8 |
9 | namespace LibSassBuilder
10 | {
11 | class Program
12 | {
13 | static async Task Main(string[] args)
14 | {
15 | var parser = new Parser(config =>
16 | {
17 | config.CaseInsensitiveEnumValues = true;
18 | config.AutoHelp = true;
19 | config.HelpWriter = Console.Out;
20 | });
21 |
22 | await parser.ParseArguments(args)
23 | .WithNotParsed(e => Environment.Exit(1))
24 | .WithParsedAsync(async o =>
25 | {
26 | switch (o)
27 | {
28 | case DirectoryOptions directory:
29 | {
30 | var program = new Program(directory);
31 |
32 | program.WriteLine($"Sass compile directory: {directory.Directory}");
33 |
34 | await program.CompileDirectoriesAsync(directory.Directory, directory.ExcludedDirectories);
35 |
36 | program.WriteLine("Sass files compiled");
37 | }
38 | break;
39 | case FilesOptions file:
40 | {
41 | var program = new Program(file);
42 | program.WriteLine($"Sass compile files");
43 |
44 | await program.CompileFilesAsync(file.Files);
45 |
46 | program.WriteLine("Sass files compiled");
47 | }
48 | break;
49 | default:
50 | throw new NotImplementedException("Invalid commandline option parsing");
51 | }
52 | });
53 | }
54 |
55 | public GenericOptions Options { get; }
56 |
57 | public Program(GenericOptions options)
58 | {
59 | Options = options;
60 | }
61 |
62 | async Task CompileDirectoriesAsync(string directory, IEnumerable excludedDirectories)
63 | {
64 | var sassFiles = Directory.EnumerateFiles(directory)
65 | .Where(file => file.EndsWith(".scss", StringComparison.OrdinalIgnoreCase) || file.EndsWith(".sass", StringComparison.OrdinalIgnoreCase));
66 |
67 | await CompileFilesAsync(sassFiles);
68 |
69 | var subDirectories = Directory.EnumerateDirectories(directory);
70 | foreach (var subDirectory in subDirectories)
71 | {
72 | var directoryName = new DirectoryInfo(subDirectory).Name;
73 | if (excludedDirectories.Any(dir => string.Equals(dir, directoryName, StringComparison.OrdinalIgnoreCase)))
74 | continue;
75 |
76 | await CompileDirectoriesAsync(subDirectory, excludedDirectories);
77 | }
78 | }
79 |
80 | async Task CompileFilesAsync(IEnumerable sassFiles)
81 | {
82 | foreach (var file in sassFiles)
83 | {
84 | var fileInfo = new FileInfo(file);
85 | if (fileInfo.Name.StartsWith("_"))
86 | {
87 | WriteVerbose($"Skipping: {fileInfo.FullName}");
88 | continue;
89 | }
90 |
91 | WriteVerbose($"Processing: {fileInfo.FullName}");
92 |
93 | var result = SassCompiler.CompileFile(file, options: Options.SassCompilationOptions);
94 |
95 | var newFile = fileInfo.FullName.Replace(fileInfo.Extension, ".css");
96 |
97 | if (File.Exists(newFile) && result.CompiledContent.ReplaceLineEndings() == (await File.ReadAllTextAsync(newFile)).ReplaceLineEndings())
98 | continue;
99 |
100 | await File.WriteAllTextAsync(newFile, result.CompiledContent);
101 | }
102 | }
103 |
104 | void WriteLine(string line)
105 | {
106 | if (Options.OutputLevel >= OutputLevel.Default)
107 | {
108 | Console.WriteLine(line);
109 | }
110 | }
111 |
112 | void WriteVerbose(string line)
113 | {
114 | if (Options.OutputLevel >= OutputLevel.Verbose)
115 | {
116 | Console.WriteLine(line);
117 | }
118 | }
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/src/LibSassBuilder/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "LibSassBuilder": {
4 | "commandName": "Project",
5 | "commandLineArgs": "../../../../LibSassBuilder.Tests"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------