Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellisense with MVC4 Style Bundling

So far I can't find a question or fix for this. I'm sure it's something simple I'm missing.

I have a style bundle with a bunch of minified CSS, and I am decorating HTML elements with the classes inside. Everything is working great.

Intellisense and ReSharper however are both bugging me about the CSS the classes being unknown. I'm guessing this is because they cannot peek inside the bundles.

Question: Is there a way to fix this?

<!-- Style Bundles in HEAD tag-->
@Styles.Render("~/bundle/style/css")
@RenderSection("styles", false);

<!-- HTML elements in BODY tag: "row" is an unknown css class -->
<div class="row">
    <p>Lorem ipsum</p>
</div>

Update: Visual Studio 2012. LESS conversion and intellisense works for single directly referenced files. My situation is that intellisense breaks when referencing a LESS bundle.

Update 2: Here's the code showing the BundleConfig.cs since it isnt clear

var customStyles = new Bundle("~/bundle/style/css")
                      .Include("~/Content/normalize.css","~/Content/*.less");
bootstrapStyles.Transforms.Add(new LessTransform());
bootstrapStyles.Transforms.Add(new CssMinify());
bundles.Add(customStyles);

Notice we are using Bundle not StyleBundle which is necessary because we want to specify the LessTransform() class and skip the built in CSS transformer. The LessTransform object is a custom object that simply reads in all the LESS content and concatenates it on a StringBuilder and then calls dotless's converter... out comes a huge CSS string that is minified and returned. The question is why cant VS or ReSharper peek at the returned CSS and help check class styles?

like image 353
one.beat.consumer Avatar asked Oct 03 '12 22:10

one.beat.consumer


People also ask

What is difference between bundling and minification?

Bundling and minification are two techniques you can use in ASP.NET to improve page load performance for your web application. Bundling combines multiple files into a single file. Minification performs a variety of different code optimizations to scripts and CSS, which results in smaller payloads.

What is bundling and minification in MVC with example?

Bundling is one of the features of MVC. By implementing this, we can improve performance request load time. Minification is the process of removing unnecessary data without changing its functionality such as removing white spaces, comments, converting the large variable names to small, etc.

What are the two types of bundles in MVC 5?

Bundle Types ScriptBundle: ScriptBundle is responsible for JavaScript minification of single or multiple script files. StyleBundle: StyleBundle is responsible for CSS minification of single or multiple style sheet files.

How does bundling and minification work in asp net core?

What is bundling and minification. Bundling and minification are two distinct performance optimizations you can apply in a web app. Used together, bundling and minification improve performance by reducing the number of server requests and reducing the size of the requested static assets.


1 Answers

Here's a post on jetbrains blog. It's a bit out of date, but Jura went on record stating that there were no plans on supporting LESS (yet).

User:

Are there any plans to support LESS? I don’t care a whole lot about full support, but it would sure be nice if it could at least bring highlighting and code completion support into .less files and have it handle nested rules.

Jura Gorohovsky :

No, no such plans yet. Can you point me to a publicly available project that uses LESS extensively so that we can take a look at it to determine the scope of work?

Link

Late edit: Web WorkBench from Mindscape may provide what some people coming to this thread are looking for. They are very response to bug fixes, and have been making some solid improvements to intellisense in the LESS world.

like image 114
samuelesque Avatar answered Oct 04 '22 14:10

samuelesque