Taritsyn / BundleTransformer

Bundle Transformer - a modular extension for System.Web.Optimization (also known as the Microsoft ASP.NET Web Optimization Framework).
Apache License 2.0
130 stars 19 forks source link

Having trouble getting Autoprefixer to work #12

Closed jakelauer closed 6 years ago

jakelauer commented 6 years ago

Some context first - I have set up BundleTransformer manually (not through NuGet) so I have manually added the necessary references to my project. I am using:

I have been using BundleTransformer successfully with Sass/Scss for a while, but I'm attempting to add Autoprefixer to the system. At this point, I managed to get everything to actually load without errors, but I the autoprefixer is not actually working. I'm having trouble figuring out what I'm doing wrong.

Here is my web.config (minus the irrelevant parts):

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <configSections>
        <sectionGroup name="bundleTransformer">
            <section name="core" type="BundleTransformer.Core.Configuration.CoreSettings, BundleTransformer.Core" />
            <section name="sassAndScss" type="BundleTransformer.SassAndScss.Configuration.SassAndScssSettings, BundleTransformer.SassAndScss" />
            <section name="autoprefixer" type="BundleTransformer.Autoprefixer.Configuration.AutoprefixerSettings, BundleTransformer.Autoprefixer" />
        </sectionGroup>
    </configSections>
    <bundleTransformer xmlns="http://tempuri.org/BundleTransformer.Configuration.xsd">
        <core>
            <css defaultPostProcessors="AutoprefixCssPostProcessor">
                <translators>
                    <add name="NullTranslator" type="BundleTransformer.Core.Translators.NullTranslator, BundleTransformer.Core" enabled="false" />
                    <add name="SassAndScssTranslator" type="BundleTransformer.SassAndScss.Translators.SassAndScssTranslator, BundleTransformer.SassAndScss" />
                </translators>
                <postProcessors>
                    <add name="AutoprefixCssPostProcessor" type="BundleTransformer.Autoprefixer.PostProcessors.AutoprefixCssPostProcessor, BundleTransformer.Autoprefixer" useInDebugMode="true" />
                </postProcessors>
                <minifiers>
                    <add name="NullMinifier" type="BundleTransformer.Core.Minifiers.NullMinifier, BundleTransformer.Core" />
                </minifiers>
                <fileExtensions>
                    <add fileExtension=".css" assetTypeCode="Css" />
                    <add fileExtension=".sass" assetTypeCode="Sass" />
                    <add fileExtension=".scss" assetTypeCode="Scss" />
                </fileExtensions>
            </css>
        </core>
        <sassAndScss useNativeMinification="false" indentType="Tab" indentWidth="2" lineFeedType="CrLf" precision="5" sourceComments="true" />
        <autoprefixer cascade="true" add="true" remove="true" supports="true" flexbox="true" grid="true" stats="">
            <jsEngine name="V8JsEngine" />
            <browsers>
                <add conditionalExpression="> 1%" />
                <add conditionalExpression="last 9 versions" />
            </browsers>
        </autoprefixer>
    </bundleTransformer>

    <runtime>
        <gcServer enabled="true" />
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
            </dependentAssembly>
            <dependentAssembly>de
                <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="LibSassHost" publicKeyToken="3e24e88796a38e46" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-1.1.3.0" newVersion="1.1.3.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="JavaScriptEngineSwitcher.Core" publicKeyToken="c608b2a8cc9e4472" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-2.4.10.0" newVersion="2.4.10.0" />
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
    <location path="." inheritInChildApplications="false">
        <system.web>
            <compilation debug="true" targetFramework="4.6.1" defaultLanguage="C#">
                <assemblies>
                    <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                    <add assembly="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                    <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                    <add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                    <add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                    <remove assembly="ClearScriptV8-64" />
                    <remove assembly="ClearScriptV8-32" />
                </assemblies>
            </compilation>
        </system.web>
    </location>
    <system.webServer>
        <handlers>
            <add name="SassAssetHandler" path="*.sass" verb="GET" type="BundleTransformer.SassAndScss.HttpHandlers.SassAndScssAssetHandler, BundleTransformer.SassAndScss" resourceType="File" preCondition="" />
            <add name="ScssAssetHandler" path="*.scss" verb="GET" type="BundleTransformer.SassAndScss.HttpHandlers.SassAndScssAssetHandler, BundleTransformer.SassAndScss" resourceType="File" preCondition="" />
        </handlers>
        <security>
            <requestFiltering>
                <hiddenSegments>
                    <add segment="LibSassHost.Native" />
                </hiddenSegments>
            </requestFiltering>
        </security>
    </system.webServer>
    <location path="." inheritInChildApplications="false">
        <system.codedom>
            <compilers>
                <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
            </compilers>
        </system.codedom>
    </location>
</configuration>

I also added this in global.asax.cs:

var v8ef = new V8JsEngineFactory();
            JsEngineSwitcher.Instance.EngineFactories.Add(v8ef);
            JsEngineSwitcher.Instance.DefaultEngineName = v8ef.EngineName;
            BundleResolver.Current = new CustomBundleResolver();
Taritsyn commented 6 years ago

Hello, Jake!

If you do not create bundles, then the BundleTransformer.Autoprefixer will not be applied.

jakelauer commented 6 years ago

@Taritsyn Sorry for the delay, I was not working on this yesterday.

I have already created bundles, but I neglected to include them in the code examples. Things are not working still.

Taritsyn commented 6 years ago

Just in case, read the “Debugging HTTP handlers” section of documentation.

jakelauer commented 6 years ago

I have determined that Autoprefixer is working, but only when I'm not in debug mode. If I disable debug mode, it works correctly. Is there a way to enable this in debug mode? I have already set useInDebugMode to true.

Taritsyn commented 6 years ago

See the “Running Autoprefixer with BundleTransformer / LESS in Debug mode” discussion on Stack Overflow.