<?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 - gj</title>
	<atom:link href="https://blog.gaiterjones.com/tag/less/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.gaiterjones.com/tag/less/</link>
	<description>gaiterjones</description>
	<lastBuildDate>Mon, 03 Jul 2017 13:20:42 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.4.3</generator>
	<item>
		<title>Magento 2 theme blank SASS parent and child setup and installation</title>
		<link>https://blog.gaiterjones.com/magento2-theme-blank-sass-parent-and-child-setup-and-installation/</link>
					<comments>https://blog.gaiterjones.com/magento2-theme-blank-sass-parent-and-child-setup-and-installation/#respond</comments>
		
		<dc:creator><![CDATA[PAJ]]></dc:creator>
		<pubDate>Mon, 03 Jul 2017 13:04:59 +0000</pubDate>
				<category><![CDATA[Docker]]></category>
		<category><![CDATA[Frontend Development]]></category>
		<category><![CDATA[Magento2]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[less]]></category>
		<category><![CDATA[magento2]]></category>
		<category><![CDATA[sass]]></category>
		<category><![CDATA[theme blank sass]]></category>
		<guid isPermaLink="false">http://blog.gaiterjones.com/?p=1712</guid>

					<description><![CDATA[With CE 1.9 Magento introduced the SASS stylesheet language to aid frontend development. With Magento 2.x for reasons best known to the developers they switched from SASS to LESS. At the...<a class="more-link" href="https://blog.gaiterjones.com/magento2-theme-blank-sass-parent-and-child-setup-and-installation/" title="Continue reading">Continue reading</a>]]></description>
										<content:encoded><![CDATA[<p>With CE 1.9 Magento introduced the <a href="http://sass-lang.com/">SASS</a> stylesheet language to aid frontend development. With Magento 2.x for <a href="https://magento.stackexchange.com/questions/26439/sass-in-1-9-less-in-2-why">reasons best known to the developers</a> they switched from SASS to LESS. At the end of the day both LESS and SASS are compiled into good old CSS but if your stylesheet language of preference is SASS or you are new to Magento and are looking for a good starting block to build a new theme from then it is well worth taking a look at <em>SnowDogApps </em><a href="https://github.com/SnowdogApps/magento2-theme-blank-sass">theme blank sass project</a>.</p>
<p>The <a href="https://community.magento.com/t5/Less-to-Sass-Community-Project/bd-p/less-to-sass">Less to Sass Community Project</a> is officially supported by Magento and Theme Blank SASS is the result of this project &#8211; a (production ready) Magento 2 blank theme converted to SASS.</p>
<p>Together with the accompanying <a href="https://github.com/SnowdogApps/magento2-frontools">Fronttools pack</a> you get the development tools and extendable SASS based blank theme you need to get you started building your own custom theme.</p>
<h1>Why use theme blank SASS ?</h1>
<ul>
<li>If you are coming from Magento 1.9 then you already are familiar with SASS</li>
<li>Magento 2.x may possibly move to SASS in the future</li>
<li>LUMA is not designed to be extended as a blank theme</li>
<li>Essential development tools such as browsersync are included</li>
</ul>
<h1>How to install theme blank SASS parent theme and Fronttools</h1>
<p>You can be up and running with theme blank SASS and fronttools in a few minutes. Here is a step by step theme blank sass and frontools installation guide tested on my <a href="https://github.com/gaiterjones/docker-magento2">Magento 2.x docker containers.</a></p>
<p>I am installing the parent theme and fronttools directly into my docker Magento 2 php-apache container with a bash script :</p>
<p><code>curl -o- http://gaiterjones.com/dropbox/magento2/theme-blank-sass/install-theme-blank-sass.sh | bash</code><br />
&nbsp;<br />
<span class="collapseomatic collapse" id="id66134113ed1d4"  tabindex="0" title="script to install theme-blank-sass and fronttools"    >script to install theme-blank-sass and fronttools</span><div id="target-id66134113ed1d4" class="collapseomatic_content ">
[bash]
#!/bin/bash<br />
# GAITERJONES<br />
# blog.gaiterjones.com<br />
# script to install theme-blank-sass and fronttools<br />
# for docker service https://github.com/gaiterjones/docker-magento2<br />
#<br />
set -e<br />
# variables<br />
RED=&#8217;&#92;&#48;33[0;31m&#8217;<br />
NC=&#8217;&#92;&#48;33[0m&#8217;</p>
<p># CHANGE THIS<br />
MAGENTO_DIR=&#8217;/var/www/dev/magento2&#8242;<br />
NVM_HOME=&#8217;/var/www&#8217;</p>
<p># start<br />
printf &quot;${RED}Installing theme-blank-sass into Magento Root: ${MAGENTO_DIR}&#8230;\n\n${NC}&quot;<br />
cd ${MAGENTO_DIR}<br />
composer require snowdog/theme-blank-sass<br />
composer require snowdog/frontools<br />
${MAGENTO_DIR}/bin/magento setup:upgrade<br />
${MAGENTO_DIR}/bin/magento cache:clean</p>
<p>printf &quot;${RED}Installing nvm&#8230;\n${NC}&quot;<br />
cd /tmp<br />
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash<br />
export NVM_DIR=${NVM_HOME}/.nvm<br />
 [ -s &quot;$NVM_DIR/nvm.sh&quot; ] &amp;&amp; \. &quot;$NVM_DIR/nvm.sh&quot;<br />
nvm install &#8211;lts<br />
nvm use &#8211;lts<br />
printf &quot;${RED}Installing gulp&#8230;\n${NC}&quot;<br />
npm install -g gulp-cli</p>
<p>printf &quot;${RED}Installing frontools&#8230;\n${NC}&quot;<br />
cd ${MAGENTO_DIR}/vendor/snowdog/frontools<br />
npm install<br />
gulp setup<br />
curl -o &quot;${MAGENTO_DIR}/dev/tools/frontools/config/themes.json&quot; http://gaiterjones.com/dropbox/magento2/theme-blank-sass/browser-sync.json<br />
curl -o &quot;${MAGENTO_DIR}/dev/tools/frontools/config/themes.json&quot; http://gaiterjones.com/dropbox/magento2/theme-blank-sass/themes-blank-sass-parent.json<br />
curl -o &quot;${MAGENTO_DIR}/vendor/snowdog/theme-blank-sass/web/images/logo.svg&quot; http://gaiterjones.com/dropbox/magento2/theme-blank-sass/logo-theme-blank-sass.svg</p>
<p>printf &quot;${RED}Generating theme-blank-sass styles&#8230;\n${NC}&quot;<br />
gulp styles</p>
<p>printf &quot;${RED}Configuring Snowdog/blank theme.\n${NC}&quot;<br />
THEME_ID=&quot;$(n98-magerun2.phar dev:theme:list &#8211;format=csv \<br />
  | grep &#8216;Snowdog/blank&#8217; | cut -d, -f1)&quot; \<br />
  ; test -n &quot;${THEME_ID}&quot; \<br />
  &amp;&amp; n98-magerun2.phar config:set design/theme/theme_id &quot;${THEME_ID}&quot;<br />
${MAGENTO_DIR}/bin/magento cache:clean</p>
<p># done<br />
printf &quot;${RED}Installation complete.\n\n${NC}&quot;<br />
[/bash]
</div>
<p>Here are the script commands broken down into some more detail :</p>
<p>Set the install environment variables</p>
<pre class="brush: bash; title: ; notranslate">
cd ${MAGENTO_DIR}
MAGENTO_DIR='/var/www/dev/magento2'
NVM_HOME='/var/www'
</pre>
<p><em>MAGENTO_DIR</em> is the path to the magento root and <em>NVM_HOME</em> the path to the NVM installation home folder &#8211; this is the home folder for the user that installs NVM</p>
<p>Install the theme and tools with composer, upgrade Magento and refresh caches.</p>
<pre class="brush: bash; title: ; notranslate">
composer require snowdog/theme-blank-sassinstall theme blank sass
composer require snowdog/frontoolsinstall fronttools

${MAGENTO_DIR}/bin/magento setup:upgradeupdate Magento
${MAGENTO_DIR}/bin/magento cache:cleanrefresh caches
</pre>
<p>Install NVM and gulp-cli</p>
<pre class="brush: bash; title: ; notranslate">
cd /tmp
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
export NVM_DIR=${NVM_HOME}/.nvm
 &#x5B; -s &quot;$NVM_DIR/nvm.sh&quot; ] &amp;&amp; \. &quot;$NVM_DIR/nvm.sh&quot;
nvm install --lts
nvm use --lts
npm install -g gulp-cli
</pre>
<p>Install frontools.</p>
<pre class="brush: bash; title: ; notranslate">
cd ${MAGENTO_DIR}/vendor/snowdog/frontools
npm install
</pre>
<p>You run the fronttools setup with <em>gulp setup</em>, this will copy the project sample configuration files to ${MAGENTO_DIR}/dev/tools/frontools/config/.  You must edit <em>themes.json</em>, for the parent theme.</p>
<pre class="brush: plain; title: ; notranslate">
{
  &quot;blank&quot;: {
    &quot;src&quot;: &quot;vendor/snowdog/theme-blank-sass&quot;,
    &quot;dest&quot;: &quot;pub/static/frontend/Snowdog/blank&quot;,
    &quot;locale&quot;: &#x5B;&quot;en_GB&quot;],
    &quot;postcss&quot;: &#x5B;&quot;plugins.autoprefixer()&quot;],
    &quot;ignore&quot;: &#x5B;&quot;.test&quot;]
  }
}

</pre>
<p>The script is copying my themes and browser-sync json configuration files via curl.</p>
<pre class="brush: bash; title: ; notranslate">
gulp setup
curl -o &quot;${MAGENTO_DIR}/dev/tools/frontools/config/themes.json&quot; http://gaiterjones.com/dropbox/magento2/theme-blank-sass/browser-sync.json
curl -o &quot;${MAGENTO_DIR}/dev/tools/frontools/config/themes.json&quot; http://gaiterjones.com/dropbox/magento2/theme-blank-sass/themes-blank-sass-parent.json
gulp styles
</pre>
<p>Next I compile the SASS to CSS and install it using</p>
<pre class="brush: bash; title: ; notranslate">
gulp styles
</pre>
<p>Finally I am using <a href="https://github.com/netz98/n98-magerun2">n98-magerun2</a> to enable the new theme, and refresh the Magento caches.</p>
<pre class="brush: bash; title: ; notranslate">
THEME_ID=&quot;$(n98-magerun2.phar dev:theme:list --format=csv \
  | grep 'Snowdog/blank' | cut -d, -f1)&quot; \
  ; test -n &quot;${THEME_ID}&quot; \
  &amp;&amp; n98-magerun2.phar config:set design/theme/theme_id &quot;${THEME_ID}&quot;
${MAGENTO_DIR}/bin/magento cache:clean
</pre>
<p><img decoding="async" src="http://gaiterjones.com/dropbox/magento2/theme-blank-sass/logo-theme-blank-sass.svg" width="248" height="73" class="aligncenter size-large" /><br />
Theme blank SASS parent theme is now installed. You can watch the install process below.</p>
<p><img decoding="async" src="https://blog.gaiterjones.com/dropbox/docker-install-magento-sass-blank-parent.gif" alt="magento 2 theme blank sass install video" class="aligncenter" /></p>
<p>We used the <em>gulp setup</em>, and <em>gulp styles </em>tasks above &#8211; other useful tasks include</p>
<ul>
<li>gulp clean
<ul>
<li><span>Removes </span><code>/pub/static</code><span> directory content.</span></li>
</ul>
</li>
<li>gulp dev
<ul>
<li><span>Runs </span><a href="https://www.browsersync.io/">browserSync</a><span> and </span><code>inheritance</code><span>, </span><code>babel</code><span>, </span><code>styles</code><span>, </span><code>watch</code><span> tasks.</span></li>
</ul>
</li>
</ul>
<p>See the fronttools project page for a full list of gulp tasks or use the gulp default task.</p>
<h1>How to install a theme blank SASS child theme</h1>
<p>Usual Magento best practice dictates that instead of editing the parent them we extend it with a child theme. You extend <code>Snowdog/blank</code> the same way as <a href="http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/themes/theme-inherit.html">any other theme</a>.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;theme xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:Config/etc/theme.xsd&quot;&gt;
    &lt;title&gt;Gaiterjones/blank&lt;/title&gt;
    &lt;parent&gt;Snowdog/blank&lt;/parent&gt;
    &lt;media&gt;
        &lt;preview_image&gt;media/preview.jpg&lt;/preview_image&gt;
    &lt;/media&gt;
&lt;/theme&gt;
</pre>
<p>I tested this with my Docker environment and used the following script to extend theme blank SASS with my <code>Gaiterjones/blank</code> child theme.</p>
<p><code>curl -o- http://gaiterjones.com/dropbox/magento2/theme-blank-sass/child/install-child-theme-blank-sass.sh | bash</code></p>
<span class="collapseomatic collapse" id="id66134113ed21a"  tabindex="0" title="script to install theme-blank-sass child theme"    >script to install theme-blank-sass child theme</span><div id="target-id66134113ed21a" class="collapseomatic_content ">
[bash]
#!/bin/bash<br />
# GAITERJONES<br />
# blog.gaiterjones.com<br />
# script to install example theme-blank-sass child theme<br />
#<br />
set -e<br />
# variables<br />
RED=&#8217;&#92;&#48;33[0;31m&#8217;<br />
NC=&#8217;&#92;&#48;33[0m&#8217;</p>
<p># CHANGE THIS<br />
MAGENTO_DIR=&#8217;/var/www/dev/magento2&#8242;<br />
NVM_HOME=&#8217;/var/www&#8217;</p>
<p># start<br />
printf &quot;${RED}Installing theme-blank-sass child theme into Magento Root: ${MAGENTO_DIR}&#8230;\n\n${NC}&quot;<br />
n98-magerun2.phar maintenance:enable<br />
cd ${MAGENTO_DIR}/app/design/frontend<br />
curl https://pe.terjon.es/dropbox/magento2/theme-blank-sass/child/gaiterjones-blank-child-theme-blank-sass.tar | tar x<br />
${MAGENTO_DIR}/bin/magento setup:upgrade<br />
cd ${MAGENTO_DIR}/vendor/snowdog/frontools</p>
<p>printf &quot;${RED}Configuring Gaiterjones/blank theme.\n${NC}&quot;<br />
THEME_ID=&quot;$(n98-magerun2.phar dev:theme:list &#8211;format=csv \<br />
  | grep &#8216;Gaiterjones/blank&#8217; | cut -d, -f1)&quot; \<br />
  ; test -n &quot;${THEME_ID}&quot; \<br />
  &amp;&amp; n98-magerun2.phar config:set design/theme/theme_id &quot;${THEME_ID}&quot;</p>
<p>printf &quot;${RED}Installing new themes.json config&#8230;\n${NC}&quot;<br />
curl -o &quot;${MAGENTO_DIR}/dev/tools/frontools/config/themes.json&quot; https://gaiterjones.com/dropbox/magento2/theme-blank-sass/child/themes-blank-sass-parent-child.json<br />
printf &quot;${RED}Generating theme-blank-sass styles&#8230;\n${NC}&quot;<br />
export NVM_DIR=${NVM_HOME}/.nvm<br />
 [ -s &quot;$NVM_DIR/nvm.sh&quot; ] &amp;&amp; \. &quot;$NVM_DIR/nvm.sh&quot;<br />
gulp styles<br />
${MAGENTO_DIR}/bin/magento cache:clean<br />
n98-magerun2.phar maintenance:disable<br />
# done<br />
printf &quot;${RED}Installation complete.\n\n${NC}&quot;</p>
[/bash]
</div>
<p>The script extracts the <code>Gaiterjones/blank</code> child theme source files to <em>app/design/frontend/Gaiterjones/blank </em>and updates Magento. We need to also update the fronttools <em>themes.json </em>config file to let fronttools know where our child theme lives</p>
<pre class="brush: plain; title: ; notranslate">
{
  &quot;blank&quot;: {
    &quot;src&quot;: &quot;vendor/snowdog/theme-blank-sass&quot;,
    &quot;dest&quot;: &quot;pub/static/frontend/Snowdog/blank&quot;,
    &quot;locale&quot;: &#x5B;&quot;en_GB&quot;],
    &quot;postcss&quot;: &#x5B;&quot;plugins.autoprefixer()&quot;],
    &quot;ignore&quot;: &#x5B;&quot;.test&quot;]
  },
  &quot;gaiterjones-blank&quot;: {
    &quot;src&quot;: &quot;app/design/frontend/Gaiterjones/blank&quot;,
    &quot;dest&quot;: &quot;pub/static/frontend/Gaiterjones/blank&quot;,
    &quot;locale&quot;: &#x5B;&quot;en_GB&quot;],
    &quot;localeOverwrites&quot;: true,
    &quot;parent&quot;: &quot;blank&quot;,
    &quot;postcss&quot;: &#x5B;&quot;plugins.autoprefixer()&quot;]
  }  
}

</pre>
<p>Next I am activating the theme with n98-magerun2 and then I simply need to refresh the caches and run <em>gulp styles </em> again to create the CSS for our child theme.</p>
<pre class="brush: bash; title: ; notranslate">
gulp styles
${MAGENTO_DIR}/bin/magento cache:clean
</pre>
<p>Fronttools compiles and installs the CSS for our child theme which is now installed and ready to view.</p>
<p><img decoding="async" src="https://blog.gaiterjones.com/dropbox/docker-install-magento-sass-blank-child.gif" alt="magento 2 theme blank sass child theme install video" class="aligncenter" /></p>
<p>You can see theme blank SASS in action on my <a href="http://magento2.gaiterjones.com" target="_blank">development site</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.gaiterjones.com/magento2-theme-blank-sass-parent-and-child-setup-and-installation/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
