BundleTransformer:Bootstrap SASS

BundleTransformer: Bootstrap SASS

我正在混合使用优秀的 BundleTransformer Nuget package to dynamically compile SCSS using the ASP.NET bundling and minification pipeline. I am attempting to bring in the bootstrap.sass 包,并不断收到以下错误。此时我的设置非常简单,scss 文件使用 node-sass 工具编译得很好,如果我删除 @import "bootstrap/bootstrap.scss" 行,SCSS 可以使用 BundleTransformer 完美编译。有没有人 运行 解决这个问题并且可能有解决方案?这是 .NET Framework 4.7.2。 谢谢!

BundleConfig.cs

        var nullBuilder = new NullBuilder();
        var styleTransformer = new StyleTransformer();
        var scriptTransformer = new ScriptTransformer();
        var nullOrderer = new NullOrderer();

        var defaultScssBundle = new CustomStyleBundle("~/bundles/styles/default");
        defaultScssBundle.Include(
            "~/Content/Default.scss"
        );
        defaultScssBundle.Builder = nullBuilder;
        defaultScssBundle.Transforms.Add(styleTransformer);
        defaultScssBundle.Transforms.Add(new CssMinify());
        defaultScssBundle.Orderer = nullOrderer;
        bundles.Add(defaultScssBundle);

Default.scss

@import "bootstrap/bootstrap.scss";

/* common styles */
.green {
    color: green;
}

.full-width {
    width: 100%;
}

错误

During translation of SCSS code, readed from the file '/TestProject/Content/bootstrap/_alert.scss', to CSS code syntax error has occurred.
See more details:

Error: Undefined variable: "$alert-padding-y".
       on line 7:12 of Content/bootstrap/_alert.scss
>>   padding: $alert-padding-y $alert-padding-x;
  -----------^

Error code: 1
Description: Undefined variable: "$alert-padding-y".
File: /TestProject/Content/bootstrap/_alert.scss
Line number: 7
Column number: 12
Source fragment:

Line 6:   position: relative;
Line 7:   padding: $alert-padding-y $alert-padding-x;
-------------------^
Line 8:   margin-bottom: $alert-margin-bottom;

经过反复试验,我发现了问题所在。查看 sample in the Github Repo 后,我从 BundleConfig.cs 中提取了以下行,现在一切正常。

defaultScssBundle.Builder = nullBuilder;
defaultScssBundle.Transforms.Add(styleTransformer);
defaultScssBundle.Transforms.Add(new CssMinify());