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

Imported scss files are added as files when EnableOptimizations is off and not in debug mode #5

Closed magnusottosson closed 6 years ago

magnusottosson commented 7 years ago

Hi,

I have a file (styles.scss) that imported other files like:

@import "Static/scss/base/_variables.scss";

In debug mode with optimizations turned off this works:

BundleTable.EnableOptimizations = true;

But if I run the code not in debug mode with optimizations turned off it seems like all the imported scss files are added in the html like:

<link href="/styles.scss?bundleVirtualPath=%7e%2fbundles%2fppak-vendor-styles" rel="stylesheet"/>
<link href="/Static/scss/base/_bootstrap-variables.scss?bundleVirtualPath=%7e%2fbundles%2fppak-vendor-styles" rel="stylesheet"/>
<link href="/Static/scss/base/_variables.scss?bundleVirtualPath=%7e%2fbundles%2fppak-vendor-styles" rel="stylesheet"/>
<link href="/Static/scss/font-awesome/_animated.scss?bundleVirtualPath=%7e%2fbundles%2fppak-vendor-styles" rel="stylesheet"/>
<link href="/Static/scss/font-awesome/_bordered-pulled.scss?bundleVirtualPath=%7e%2fbundles%2fppak-vendor-styles" rel="stylesheet"/>
<link href="/Static/scss/font-awesome/_core.scss?bundleVirtualPath=%7e%2fbundles%2fppak-vendor-styles" rel="stylesheet"/>
<link href="/Static/scss/font-awesome/_fixed-width.scss?bundleVirtualPath=%7e%2fbundles%2fppak-vendor-styles" rel="stylesheet"/>
<link href="/Static/scss/font-awesome/_icons.scss?bundleVirtualPath=%7e%2fbundles%2fppak-vendor-styles" rel="stylesheet"/>
<link href="/Static/scss/font-awesome/_larger.scss?bundleVirtualPath=%7e%2fbundles%2fppak-vendor-styles" rel="stylesheet"/>
<link href="/Static/scss/font-awesome/_list.scss?bundleVirtualPath=%7e%2fbundles%2fppak-vendor-styles" rel="stylesheet"/>
<link href="/Static/scss/font-awesome/_mixins.scss?bundleVirtualPath=%7e%2fbundles%2fppak-vendor-styles" rel="stylesheet"/>
<link href="/Static/scss/font-awesome/_path.scss?bundleVirtualPath=%7e%2fbundles%2fppak-vendor-styles" rel="stylesheet"/>
<link href="/Static/scss/font-awesome/_rotated-flipped.scss?bundleVirtualPath=%7e%2fbundles%2fppak-vendor-styles" rel="stylesheet"/>
<link href="/Static/scss/font-awesome/_stacked.scss?bundleVirtualPath=%7e%2fbundles%2fppak-vendor-styles" rel="stylesheet"/>
<link href="/Static/scss/font-awesome/_variables.scss?bundleVirtualPath=%7e%2fbundles%2fppak-vendor-styles" rel="stylesheet"/>
<link href="/Static/scss/font-awesome/font-awesome.scss?bundleVirtualPath=%7e%2fbundles%2fppak-vendor-styles" rel="stylesheet"/>

This gives 500 errors since these files are not in the bundle. The correct implementation here would be that the is process as an scss file. Everything seems to be working except that the imported scss files should not be written to the html since they are not a part of the bundle...

This error only happens when running the code not in debug mode with enable optimisations turned off.

Taritsyn commented 7 years ago

Hello, Magnus!

You are using a code from the “Control Minification per Request with Web Optimizations” article?

Taritsyn commented 7 years ago

Hello, Magnus!

I decided not to wait for your answer and explain the essence of problem. Regarding @imports (as well as other types of file dependencies): currently the Microsoft ASP.NET Web Optimization Framework do not gives us opportunities to directly manage the cache dependencies of bundle, and therefore we can only add @imports to the Files property of BundleResponse class.

In most cases, this specificity of implementation will not cause any problems. I couldn't even reproduce the error, that you described. Most likely, in your web application there are some non-standard add-ins. Four years ago I was faced with a similar add-in.

You could make a demonstration project, which reproduce this error.

Taritsyn commented 6 years ago

Hello, Magnus!

Since I did not receive feedback from you, then I close this issue.