Welcome to the first episode in our new video series for Emulsify. Emulsify 2.x is a new release that embodies our commitment to component-driven design within Drupal. We’ve added Composer and Drush support, as well as open-source Twig functions and many other changes to increase ease-of-use.
In this video, we’re going to get you up and running with Emulsify. This blog post accompanies a tutorial video, which you can find embedded at the end.
Emulsify is, at it’s core, a prototyping tool. At Four Kitchens we also use it as a Drupal 8 theme starter kit. Depending on how you want to use it, the installation steps will vary. I’ll quickly go over how to install and use Emulsify as a stand alone prototyping tool, then I’ll show you how we use it to theme Drupal 8 sites.
Installing Emulsify core as a stand alone tool is a simple process with Composer and NPM (or Yarn).
composer create-project fourkitchens/emulsify --stability dev --no-interaction emulsify
npm install, if you don’t have yarn installed)
Once the installation process is complete, you can start it with either
npm start or
Once it’s up, you can use the either the Local or External links to view the Pattern Lab instance in the browser. (The External link is useful for physical device testing, like on your phone or tablet, but can vary per-machine. So, if you’re using hosted fonts, you might have to add a bunch of IPs to your account to accommodate all of your developers.)
The start process runs all of the build and watch commands. So once it’s up, all of your changes are instantly reflected in the browser.
I can add additional colors to the
_color-vars.scss file, Edit the
card.yml example data, or even update the
01-card.twig file to modify the structure of the card component.
That’s really all there is to using Emulsify as a prototyping tool. You can quickly build out your components using component-driven design without having to have a full web server, and site, up and running.
Emulsify in a Composer-Based Drupal 8 Installation
It’s general best practice to install Drupal 8 via Composer, and that’s what we do at Four Kitchens. So, we’ve built Emulsify 2 to work great in that environment. I won’t cover the details of installing Drupal via Composer since that’s out of scope for this video, and there are videos that cover that already. Instead, I’ll quickly run through that process, and then come back and walk through the details of how to install Emulsify in a Composer-based Drupal 8 site.
Okay, I’ve got a fresh Drupal 8 site installed. Let’s install Emulsify alongside it.
From the project root, we’ll run the composer require command:
composer require fourkitchens/emulsify
Next, we’ll enable Emulsify and its dependencies:
drush en emulsify components unified_twig_ext -y
At this point, we highly recommend you use the Drush script that comes with Emulsify to create a custom clone of Emulsify for your actual production site. The reason is that any change you make to Emulsify core will be overwritten when you update Emulsify, and there’s currently no real good way to create a child theme of a component-based, Pattern Lab -powered, Drupal theme. So, the Drush script simply creates a clone of Emulsify and makes the file renaming process into a simple script.
We have another video covering the Drush script, so definitely watch that for all of the details. For this video though, I’ll just use emulsify core, since I’m not going to make any customizations.
cd web/themes/contrib/emulsify/(If you do create a clone with the drush script, you’ll
Now we have our Pattern Lab instance up and running, accessible at the links provided.
We can also head over to the “Appearance” page on our site, and set our theme as the default. When we do that, and go back to the homepage, it looks all boring and gray, but that’s just because we haven’t started doing any actual theming yet.
At this point, the theme is installed, and you’re ready to create your components and make your site look beautiful!
Thanks for following our Emulsify 2.x tutorials. Miss a post? Read the full series is here.
Pt 1: Installing Emulsify | Pt 2: Creating your Emulsify 2.0 Starter Kit with Drush | Pt 3: BEM Twig Function | Pt 4: DRY Twig Approach | Pt 5: Building a Full Site Header in Drupal
Just need the videos? Watch them all on our channel.