<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Chris Sargent on Medium]]></title>
        <description><![CDATA[Stories by Chris Sargent on Medium]]></description>
        <link>https://medium.com/@chris5argent?source=rss-eaf6dc7b0a90------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FQqfjZpQY_Fu-oqfs5EG-Q.jpeg</url>
            <title>Stories by Chris Sargent on Medium</title>
            <link>https://medium.com/@chris5argent?source=rss-eaf6dc7b0a90------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 06:14:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chris5argent/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Hello Build System World!]]></title>
            <link>https://chris5argent.medium.com/hello-build-system-world-3746ebce5762?source=rss-eaf6dc7b0a90------2</link>
            <guid isPermaLink="false">https://medium.com/p/3746ebce5762</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[grunt]]></category>
            <dc:creator><![CDATA[Chris Sargent]]></dc:creator>
            <pubDate>Sun, 30 Aug 2015 16:31:23 GMT</pubDate>
            <atom:updated>2015-09-01T10:27:40.310Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>Part 2. Setup AutoPrefixer and Minifier / Uglifier</strong></h4><p><em>Developing out my Grunt Build System by Chris Sargent of </em><a href="http://www.stickypixel.com/"><em>Sticky Pixel</em></a></p><p>CAVEAT! This isn’t really meant to be a tutorial as such because this is the first time I’ve done this and I’m not sure I’m using best practices etc. I just wanted to write it to help me learn and maybe help someone else if they ran in to some of the same issues. I wrote it whilst setting up Grunt myself, predominantly inspired by this video:<a href="https://www.youtube.com/watch?v=TMKj0BxzVgw">https://www.youtube.com/watch?v=TMKj0BxzVgw</a> from Will at <a href="https://www.youtube.com/channel/UCVTlvUkGslCV_h-nSAId8Sw">Learn Code Academy</a> and several videos from Travis at<a href="https://www.youtube.com/channel/UCyIe-61Y8C4_o-zZCtO4ETQ">Dev Tips</a> (If you haven’t already you should definitely check out their YouTube channels). I don’t follow it exactly because I’m setting it up for my workflow, but I was certainly inspired by the videos to do it. Another really good video is from Chris Coyier of CSS Tricks here: <a href="https://www.youtube.com/watch?v=Mr2VBRdRYak">https://www.youtube.com/watch?v=Mr2VBRdRYak</a>.</p><p><a href="https://github.com/ChrisSargent/Build-System-Tutorial-Part-1"><strong>Part 1</strong></a></p><ul><li>Install Grunt</li><li>Setup SASS Compiler</li><li>Setup Concatenate Javascript</li><li>Setup watch on save</li></ul><p><strong>Part 2</strong></p><ul><li>Auto-Prefixing CSS and using CSSNext for the future</li><li>Uglify JS and CSS (compress / minify)</li><li>JSHint</li></ul><p><strong>Part 3</strong></p><ul><li>Local Server</li><li>Live Reload</li></ul><p>Last time out I started to setup my development environment using Grunt and installed a SASS compliler, Javascript Concatenate and Watch in to Grunt. This time I’m gonna get my CSS code browser compatible with an AutoPrefixer, shorten my page load times by Uglifying my Javascript and start using JSHint to alert me of any issues in my Javascript.</p><h2>Setup CSSNext (Includes AutoPrefixer)</h2><p><a href="https://github.com/cssnext/grunt-cssnext">https://github.com/cssnext/grunt-cssnext</a></p><p>Originally, I was going to setup AutoPrefixer but when I visited their Github page (<a href="https://github.com/ndmitry/grunt-autoprefixer">https://github.com/ndmitry/grunt-autoprefixer</a>), I saw that it was in fact, deprecated in favour of PostCSS. So I started to install that from their Github page instead (<a href="https://github.com/nDmitry/grunt-postcss">https://github.com/nDmitry/grunt-postcss</a>). But, as it turns out, you don’t need PostCSS if you’re going to use CSSNext with Grunt and since CSSNext (which I wanted to use anyway) includes AutoPrefixer, I decided to just go for that instead. Cssnext is a CSS transpiler that allows you to use the latest CSS syntax today. It transforms new CSS specs into more compatible CSS so you don’t need to wait for browser support. In addition, it will AutoPrefix my CSS code with Browser-Specific prefixes.</p><p>However, I will still write and use SASS files for now because I prefer the way that SASS deals with variables. Reading the specs of the CSS3 variables looks odd and to me it just seems they have the declaration and usage the wrong way around. Would seem much more logical and intuitive to me to use a similar syntax and method of doing it as Javascript but hey, who the hell am I to think that?!</p><p>So, I went ahead and installed CSSNext by running this command from the Terminal in my Project Folder</p><pre>$ npm install --save-dev grunt-cssnext</pre><p>As before this automatically included a reference to Watch in my package.json file. Then I added the following to the Gruntfile:</p><pre>grunt.loadNpmTasks(&quot;grunt-cssnext&quot;);</pre><p>Then I added some configuration code to my Gruntfile, taken from their Github examples — you can see it in my final code on Github.</p><p>I’d also recommend reading these articles for a bit more info about the SASS compiler vs the PostCSS transpiler<a href="http://benfrain.com/breaking-up-with-sass-postcss/">http://benfrain.com/breaking-up-with-sass-postcss/</a> and <a href="https://blog.colepeters.com/on-writing-real-css-again/">https://blog.colepeters.com/on-writing-real-css-again/</a>.</p><h2>Setup Uglify</h2><p><a href="https://github.com/gruntjs/grunt-contrib-uglify">https://github.com/gruntjs/grunt-contrib-uglify</a></p><p>Next up, I installed Uglify in much the same way as all the other plugins, by running this command from the Terminal in my Project Folder</p><pre>$ npm install grunt-contrib-uglify --save-dev</pre><p>Which automatically included a reference to Uglify in my package.json file. Then I added the following to the Gruntfile:</p><pre>grunt.loadNpmTasks(&quot;grunt-grunt-contrib-uglify&quot;);</pre><p>This way of installing is getting pretty familiar now! Finally, I added some configuration code to my Gruntfile, taken from their Github examples. After installing Uglify, I realised that actually, it doesn’t also Uglify CSS files (I guess I should have read the specs more!). But no worries, we can change the config of our SASS compiler so that it outputs compressed CSS instead. To do so I simply needed to change the following line in the SASS section of my Gruntfile:</p><pre>compress: false,</pre><p>to</p><pre>style: &#39;compressed&#39;,</pre><p>I now had very ugly CSS and Javascript files! Happily, the CSSNext plugin which is adding the browser prefixes to my CSS code doesn’t seem to add any additional white space or break the ugliness either.</p><h2>Setup JSHint</h2><p><a href="https://github.com/gruntjs/grunt-contrib-jshint">https://github.com/gruntjs/grunt-contrib-jshint</a></p><p>Finally for this part, I installed JSHint which will help alert me to errors in my code before I preview them in a browser. In the same way as all the other plugins, I installed it by running this command from the Terminal in my Project Folder</p><pre>$ npm install grunt-contrib-jshint --save-dev</pre><p>Which automatically included a reference to JSHint in my package.json file. Then I added the following to the Gruntfile:</p><pre>grunt.loadNpmTasks(&#39;grunt-contrib-jshint&#39;);</pre><p>Finally, I added some configuration code to my Gruntfile, taken from their Github examples — because we’re concatenating our Javascript files, I used their configuration example for that scenario.</p><h2>Finally…</h2><p>That’s it for this part. I’ve now got Grunt up and running, it’s compiling my SASS, compressing my CSS files, concatenating my JS files, telling me what’s wrong with it and finally minifying my javascript! Sweet. Next time, I’m going to set up the Grunt local server and live reload. As a nice bonus, I’m becoming much more familiar with Github terminal commands.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3746ebce5762" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hello Build System World!]]></title>
            <link>https://chris5argent.medium.com/hello-build-system-world-7192ce74f4e7?source=rss-eaf6dc7b0a90------2</link>
            <guid isPermaLink="false">https://medium.com/p/7192ce74f4e7</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[grunt]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Chris Sargent]]></dc:creator>
            <pubDate>Sun, 12 Jul 2015 18:51:25 GMT</pubDate>
            <atom:updated>2015-09-01T10:27:01.489Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>Part 1. Install Grunt, Setup SASS Compiler, Concatenate &amp; Watch.</strong></h4><p><em>Developing out my Grunt Build System by Chris Sargent of </em><a href="http://www.stickypixel.com/"><em>Sticky Pixel</em></a></p><p>I’ve been thinking for some time that I really need to sort out a ‘build system’ for myself. After watching several tutorials I’d noticed that most of the presenters were using them and they certainly seemed to help for automating a lot of the mundane tasks I was constantly doing. I also wanted to start making my projects a lot more ‘familiar’ and trying to build them out in as modular, resuable fashion as possible. To do this I knew I needed a task manager and Grunt or Gulp seem to be the apps of choice just now so I decided to try Grunt. The thing to remember about Grunt is that it is <strong>just </strong>a task runner; nothing more, nothing less. You install it and then you need to tell it which tasks to run and when to run them.</p><p>CAVEAT! This isn’t really meant to be a tutorial as such because this is the first time I’ve done this and I’m not sure I’m using best practices etc. I just wanted to write it to help me learn and maybe help someone else if they ran in to some of the same issues. I wrote it whilst setting up Grunt myself, predominantly inspired by this video: <a href="https://www.youtube.com/watch?v=TMKj0BxzVgw">https://www.youtube.com/watch?v=TMKj0BxzVgw</a> from Will at <a href="https://www.youtube.com/channel/UCVTlvUkGslCV_h-nSAId8Sw">Learn Code Academy</a> and several videos from Travis at <a href="https://www.youtube.com/channel/UCyIe-61Y8C4_o-zZCtO4ETQ">Dev Tips</a> (If you haven’t already you should definitely check out their YouTube channels). I don’t follow it exactly because I’m setting it up for my workflow, but I was certainly inspired by the videos to do it. Another really good video is from Chris Coyier of CSS Tricks here: <a href="https://www.youtube.com/watch?v=Mr2VBRdRYak">https://www.youtube.com/watch?v=Mr2VBRdRYak</a>.</p><p>My Github code: <a href="https://github.com/ChrisSargent/Build-System-Tutorial-Part-1">https://github.com/ChrisSargent/Build-System-Tutorial-Part-1</a></p><p><a href="https://github.com/ChrisSargent/Build-System-Tutorial-Part-1"><strong>Part 1</strong></a></p><ul><li>Install Grunt</li><li>Setup SASS Compiler</li><li>Setup Concatenate Javascript</li><li>Setup watch on save</li></ul><p><a href="https://github.com/ChrisSargent/Build-System-Tutorial-Part-2"><strong>Part 2</strong></a></p><ul><li>Auto-Prefixing CSS and using CSSNext for the future</li><li>Uglify JS and CSS (compress / minify)</li><li>JSHint</li></ul><p><strong>Part 3</strong></p><ul><li>Local Server</li><li>Live Reload</li></ul><h3>Installing Grunt Command Line</h3><p>First off, I installed Node.js from <a href="https://nodejs.org/">https://nodejs.org/</a> then installed the Grunt CLI using:</p><pre>$ npm install -g grunt-cli</pre><p><em>Beware the following comment from the Grunt website!</em></p><blockquote><em>Before setting up Grunt ensure that your npm is up-to-date by running npm update -g npm (this might require sudo on certain systems).</em></blockquote><p><em>In my case, I did need to run it using </em><strong><em>sudo</em></strong><em>. The first time I did it, I didn’t use </em><strong><em>sudo</em></strong><em>, it failed and prevent </em><strong><em>npm</em></strong><em> from working (file or directory not found error). I had to reinstall node to get it working, then ran it with </em><strong><em>sudo</em></strong><em> and I was good to go.</em></p><h3>Create a New Project</h3><p>I then created a new Project Folder in Finder (or you can use your favourite text editor) using a very basic directory structure, a bit like this:</p><pre>+-- build<br>|   +-- all my build files / folders will end up here<br>+-- sass<br>|   +-- _layout.scss<br>|   +-- _reset.scss<br>|   +-- _typography.scss<br>|   +-- base.scss<br>+-- js<br>|   +-- main.js<br>|   +-- snippets.js<br>+-- Gruntfile.js<br>+-- index.html<br>+-- package.json</pre><p>Each Project that I want to use Grunt with will need a Gruntfile.js and package.json in its root directory. So I initially created a Gruntfile.js with the following contents:</p><pre>module.exports = function (grunt) {};</pre><pre>and a package.json file with the following contents:</pre><pre>{<br>  &quot;name&quot;: &quot;my-project-name&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;author&quot;: &quot;You&quot;,<br>  &quot;dependencies&quot;: {},<br>  &quot;devDependencies&quot;: {}<br>}</pre><p>I also created a blank package.json file and used some boilerplate code from the Grunt website. Alternatively, I could have used</p><pre>$ npm init</pre><p>from the terminal in my Project Folder which would have created a basic package.json file but I preferred to create it myself for now. The great thing about using <strong>npm</strong> and a package.json file (I believe) is that it makes it very easy for people to duplicate your project later and automatically install all it’s dependencies.</p><h3>Installing Grunt in to My Project</h3><p>I now needed to install Grunt in to the specific project I was working on. From the Terminal window, whilst in my Project Folder, I ran:</p><pre>$ npm install -S grunt</pre><p>which created a folder in my project called node_modules, installed Grunt into that folder and included it as a dependency in the package.json file (Be sure to include the –S to ensure the package.json file is automatically updated). Grunt was now installed in my project so I could now install and setup some tasks for it to run.</p><h3>Setup SASS Compiler</h3><p><a href="https://github.com/gruntjs/grunt-contrib-sass">https://github.com/gruntjs/grunt-contrib-sass</a></p><p>With Grunt now installed in my project, I could then install various plugins from the Grunt website. In this case, I installed the SASS Compiler right from the get-go.</p><p>Despite planning to later setup the CSSNext transpiler, I still wanted to be able to handle SASS files because I’m more familiar with them at the moment. I see no real harm in continuing to use a pre-processor that gives tremendous value and features and a post-processor at the same time. Eventually, maybe we’ll be using vanilla CSS3 variables but for now, this will do!</p><p>So, I installed the SASS compiler from the Grunt team (link is above) by running this command from the Terminal in my Project Folder:</p><pre>$ npm install grunt-contrib-sass --save-dev</pre><p>This automatically included a reference to SASS in my package.json file. It took a few minutes to complete on my machine.</p><p>So, the SASS compiler was now installed but as yet Grunt was not being instructed to run it. Therefore, in my Gruntfile.js I needed to add the following line to enable the SASS task to be loaded:</p><pre>grunt.loadNpmTasks(&quot;grunt-contrib-sass&quot;);</pre><p>I also needed to add some config details to the Gruntfile.js and the best source of information for this is the relevant documentation on Github. However, you can see my final config in my files on GitHub.</p><p>Note that the SASS task also requires Ruby and Sass to be installed. If you’re on OS X or Linux you probably already have Ruby installed; test in your terminal with</p><pre>$ ruby –v</pre><p>and</p><pre>$ sass –v</pre><p>If you have confirmed you have Ruby installed but not SASS, you can run the following command to install Sass. (You may not need to use the Sudo part but I did)</p><pre>$ sudo gem install sass</pre><p>Also note that SASS files (.sass, .scss) whose filename begins with “_” are ignored even if they match the pattern in the config in the Gruntfile.js. This is done to match the expected Sass partial behaviour. In my config, I also set it up to not create .map files and to not compress it because I will use a minifier to do that later.</p><p>At this point and after reading the Grunt SASS documentation, although I realised I didn’t really need the Concatenate function for the CSS because I would handle this via @import’s in my SASS files, I would still need it for Javascript files. So I continued on to installing the Grunt Concatenate function.</p><h3>Setup Concatenate</h3><p><a href="https://github.com/gruntjs/grunt-contrib-concat">https://github.com/gruntjs/grunt-contrib-concat</a></p><p>To install the Concatenate function, I ran this command from the Terminal in my Project Folder</p><pre>$ npm install grunt-contrib-concat --save-dev</pre><p>As before, this automatically included a reference to Concatenate in my package.json file.</p><p>Once again, the Concatenate function was now installed but Grunt was not being instructed to run it. Therefore, in my Gruntfile.js I added the following line to enable the Concatenate task to be loaded:</p><pre>grunt.loadNpmTasks(&#39;grunt-contrib-concat&#39;);</pre><p>I also needed to add some config details to the Gruntfile.js and the best source of information for this is the relevant documentation on Github. However, you can see my final config in my files on GitHub.</p><p>And that’s it for the Concatenation; files in my JS folder ending in .js will now be concatenated to one file which will help considerably with page load times.</p><h3>Setup Watch</h3><p><a href="https://github.com/gruntjs/grunt-contrib-watch">https://github.com/gruntjs/grunt-contrib-watch</a></p><p>Finally for Part 1, I installed Watch so that my desired Grunt tasks would be automatically run when I save my files:</p><p>To install it, I ran this command from the Terminal in my Project Folder</p><pre>$ npm install grunt-contrib-watch --save-dev</pre><p>As before this automatically included a reference to Watch in my package.json file.</p><p>Then I added the following to the Gruntfile:</p><pre>grunt.loadNpmTasks(&#39;grunt-contrib-watch&#39;);</pre><p>And, of course, I added some configuration to my Gruntfile.js.</p><p>So finally, here’s my Gruntfile.js after installing the SASS compiler, Concatenate and Watch. I also added a default option so that you can just run Grunt and the watch starts automatically:<a href="https://github.com/ChrisSargent/Build-System-Tutorial-Part-1/blob/master/Gruntfile.js">https://github.com/ChrisSargent/Build-System-Tutorial-Part-1/blob/master/Gruntfile.js</a></p><p>And here’s my package.json file after installing Concatenate and Watch:<a href="https://github.com/ChrisSargent/Build-System-Tutorial-Part-1/blob/master/package.json">https://github.com/ChrisSargent/Build-System-Tutorial-Part-1/blob/master/package.json</a></p><p>So to make this all work when I’m working on a project, I simply need to open a Terminal window, navigate to my Project Folder and then enter the following command:</p><pre>$ grunt</pre><p>My .scss files and .js files will now be automatically compiled and concatenated whenever I save them and will be output to my build folder for deployment. As a by-product, by writing this tutorial and putting it on Github, I’m also getting more familiar with Git terminal commands and trying to write my code like other people might see it sometime.</p><h3>Finally</h3><p>So that’s it for now; next up, I’m adding the Auto-Prefixer and minifier / Uglifier.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7192ce74f4e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>