<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LESS Archives - Michael Soriano</title>
	<atom:link href="https://michaelsoriano.com/tag/less/feed/" rel="self" type="application/rss+xml" />
	<link>https://michaelsoriano.com/tag/less/</link>
	<description>I turn code into captivating user experiences for the web</description>
	<lastBuildDate>Mon, 26 Oct 2015 04:45:52 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.4</generator>
	<item>
		<title>Working with LESS, Atom and Chrome Developer Tools</title>
		<link>https://michaelsoriano.com/working-with-less-atom-and-chrome-developer-tools/</link>
					<comments>https://michaelsoriano.com/working-with-less-atom-and-chrome-developer-tools/#comments</comments>
		
		<dc:creator><![CDATA[Michael Soriano]]></dc:creator>
		<pubDate>Mon, 26 Oct 2015 04:45:52 +0000</pubDate>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Atom]]></category>
		<category><![CDATA[LESS]]></category>
		<guid isPermaLink="false">http://michaelsoriano.com/?p=5276</guid>

					<description><![CDATA[<p>One of the many ways to increase a developer&#8217;s productivity is to utilize tools such as LESS. LESS is a CSS pre-compiler that extends the capabilities of the CSS language. You can use variables, functions as well as nested rules &#8211; things that you cannot do in plain CSS. I&#8217;m not going to dig deep [&#8230;]</p>
<p>The post <a href="https://michaelsoriano.com/working-with-less-atom-and-chrome-developer-tools/">Working with LESS, Atom and Chrome Developer Tools</a> appeared first on <a href="https://michaelsoriano.com">Michael Soriano</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>One of the many ways to increase a developer&#8217;s productivity is to utilize tools such as LESS. <a href="http://lesscss.org/">LESS</a> is a CSS pre-compiler that extends the capabilities of the CSS language. You can use variables, functions as well as nested rules &#8211; things that you cannot do in plain CSS. I&#8217;m not going to dig deep into LESS &#8211; I suggest you go their website and find out more for yourself. Just trust me in saying &#8211; it will save you countless hours of writing CSS.<br />
<img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-5291" src="https://michaelsoriano.com/wp-content/uploads/2015/10/less-atom.jpg" alt="less-atom" width="700" height="278" srcset="https://michaelsoriano.com/wp-content/uploads/2015/10/less-atom.jpg 700w, https://michaelsoriano.com/wp-content/uploads/2015/10/less-atom-300x119.jpg 300w" sizes="(max-width: 700px) 100vw, 700px" /><br />
Now there is a couple of drawbacks to using LESS. One &#8211; you have to compile your .less files so it becomes .css. The other, is debugging. Since your CSS files are now a compiled version of your original code &#8211; debugging it in the browser can be a pain. The line numbers and and file names referenced are all in <strong>.css</strong> &#8211; not your <strong>.less</strong> files.</p>
<h6>Compiling</h6>
<p>Let&#8217;s tackle the first drawback: compiling less. Yes it&#8217;s a pain in the butt having to write your code, then going to the command line to compile. Since I use Atom for my editor, there is a plugin called <a href="https://atom.io/packages/less-autocompile">less-autocompile</a> which compiles our less files each time you save.<br />
First, start Atom, and download the package. Go to &#8220;<strong>File</strong>&#8220;, &#8220;<strong>Settings</strong>&#8220;, &#8220;<strong>Packages</strong>&#8220;.<br />
<img decoding="async" class="alignnone size-full wp-image-5282" src="https://michaelsoriano.com/wp-content/uploads/2015/10/less-0.jpg" alt="less-0" width="700" height="404" srcset="https://michaelsoriano.com/wp-content/uploads/2015/10/less-0.jpg 700w, https://michaelsoriano.com/wp-content/uploads/2015/10/less-0-300x173.jpg 300w" sizes="(max-width: 700px) 100vw, 700px" /><br />
Once installed, you can start writing your LESS code right away. Make sure you write a comment on the first line: &#8220;<strong>//out: styles.css</strong>&#8221; &#8211; so the plugin can know what and where to output your CSS file. Once you hit &#8220;<strong>Save</strong>&#8220;, you should see your new <strong>.css</strong> file created.<br />
<img decoding="async" class="alignnone size-full wp-image-5280" src="https://michaelsoriano.com/wp-content/uploads/2015/10/less-2.jpg" alt="less-2" width="700" height="404" srcset="https://michaelsoriano.com/wp-content/uploads/2015/10/less-2.jpg 700w, https://michaelsoriano.com/wp-content/uploads/2015/10/less-2-300x173.jpg 300w" sizes="(max-width: 700px) 100vw, 700px" /><br />
So how easy is that? No command line, no other software &#8211; just compile right in your editor. Note that you should check your IDE for a plugin that&#8217;s similar. I&#8217;m sure there are plenty out there.</p>
<h6>Debugging</h6>
<p>The second drawback is debugging. Let&#8217;s inspect our HTML and see the debugging problem that I was talking about previously.<br />
<img decoding="async" class="alignnone size-full wp-image-5285" src="https://michaelsoriano.com/wp-content/uploads/2015/10/chrome-tools.gif" alt="chrome-tools" width="671" height="489" /><br />
You see that the rule referenced goes back to our <strong>.css</strong> file! We need it to look into our <strong>.less</strong> file!<br />
Luckily, we have <a href="http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/">Sourcemaps</a> to the rescue. <strong>Sourcemaps</strong> is a way to map compiled / minified code back to its original source. This is especially useful for debugging and tracing code.<br />
Make sure in Chrome, that the &#8220;<strong>Enable CSS source maps</strong>&#8221; option is checked.<br />
<img decoding="async" class="alignnone size-full wp-image-5287" src="https://michaelsoriano.com/wp-content/uploads/2015/10/sourcemap-chrome1.jpg" alt="sourcemap-chrome1" width="598" height="478" srcset="https://michaelsoriano.com/wp-content/uploads/2015/10/sourcemap-chrome1.jpg 598w, https://michaelsoriano.com/wp-content/uploads/2015/10/sourcemap-chrome1-300x240.jpg 300w" sizes="(max-width: 598px) 100vw, 598px" /><br />
Now back to our Atom IDE, our plugin less-autompile also supports outputting sourcemaps on save. So back to the first line of comment in our <strong>.less</strong> file, add &#8220;<strong>sourcemap: true</strong>&#8220;. Now save the your .less file and a sourcemap file will be added.<br />
One thing I noticed though that I had to manually add another comment in the bottom of my .less file: &#8220;<strong>/*# sourceMappingURL=styles.css.map */</strong>&#8220;. This is to tell Chrome Developer tools where our .map file is.<br />
Now refresh the page that you&#8217;re inspecting and see the file it&#8217;s referencing to. Notice that its now pointing to our <strong>.less</strong> file! Problem solved.<br />
<img decoding="async" class="alignnone size-full wp-image-5288" src="https://michaelsoriano.com/wp-content/uploads/2015/10/sourcemap-chrome2.jpg" alt="sourcemap-chrome2" width="598" height="385" srcset="https://michaelsoriano.com/wp-content/uploads/2015/10/sourcemap-chrome2.jpg 598w, https://michaelsoriano.com/wp-content/uploads/2015/10/sourcemap-chrome2-300x193.jpg 300w" sizes="(max-width: 598px) 100vw, 598px" /><br />
In closing, knowing the right tools for doing your job is key to increased productivity. Web development is no different. Thanks to LESS, Atom and plugins such as less-autocompile, we are well on our way to CSS success.</p>
<p>The post <a href="https://michaelsoriano.com/working-with-less-atom-and-chrome-developer-tools/">Working with LESS, Atom and Chrome Developer Tools</a> appeared first on <a href="https://michaelsoriano.com">Michael Soriano</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://michaelsoriano.com/working-with-less-atom-and-chrome-developer-tools/feed/</wfw:commentRss>
			<slash:comments>7</slash:comments>
		
		
			</item>
	</channel>
</rss>
