sass / libsass-net

A lightweight wrapper around libsass
MIT License
94 stars 35 forks source link

@import statements not processed #40

Closed ericrovtar closed 7 years ago

ericrovtar commented 8 years ago

Hi! I'm trying to implement this in order to compile my Sass in a bundle for my MVC project.

In my BundleConfig.cs file, I have the following: bundles.Add(new StyleBundle("~/bundles/styles").Include("~/Content/2016-Q1/styles/_CCC/sass/styles.scss"));

styles.scss is my main SASS file, with a bunch of @import statements.

When I build the project and load a View, the CSS file simply the @import statements minimized: @import"_vars.scss";@import"includes/reset.scss";@import"includes/box-sizing.scss";@import"includes/csswizardry-grids.scss";@import"includes/typecsset.scss";@import"includes/flexbox.scss";@import"_mixins.scss";@import"_namespaces.scss";@import"_hacks.scss";

Am I missing something? The bundle is loading. The issue is that the SASS isn't compiling.

Any help would be appreciated.

Thanks!

-Eric

aviatrix commented 8 years ago

Hey, the problem is lies within !

You should use SassBundle instead of StyleBundle.

also if you include .css files in the scss bundles rename them to .scss and check the content type of the file in VS before commiting , sometimes it changes it to "none" and it should be "Content", "none" causes the file not to be copied over when building & deploying :)

bundles.Add(new SassBundle("~/bundles/styles").Include("~/Content/2016-Q1/styles/_CCC/sass/styles.scss")); is the correct way :)

ericrovtar commented 8 years ago

Thanks, @aviatrix, but I don't thank that's correct. First, the documentation specifically says to just use StyleBundle and, second, SassBundle isn't recognized.

I did some playing around and started by turning off optimization. I also added some basic sass rules to my styles.scss file: .a { .b { font-weight: bold; } }

This triggered something as things started to compile.

There were a few errors in my Sass markup, so I corrected those and then my Sass compiled as expected.

I then tried to remove those rules I had added, and rebuilt the project. Again, the Sass compiled.

So now the final step was to turn on Optimization again: BundleTable.EnableOptimizations = true;

I did that and then rebuilt my project again and that's when it didn't compile. So it seems to have to do with this setting, but I also don't want my Sass files to compile every time. I'd like them cached.

At least now I know what's going on, so if anyone has a solution to this, that would be great.

Thanks!