Bummer! This is just a preview. You need to be signed in with a Pro account to view the entire video.
Start a free Basic trial
to watch this video
Take the Pain Out of Sass - Ian Carrico
48:17 with Ian CarricoManaging multiple projects, multiple developers, or different development environments on a project makes Sass quickly go from an awesome tool to a painful test in debugging. But it does not have to be this way! There are tools, and methods to quickly and easily manage each individual project to use consistent versions of Ruby, the proper gems, and deploy code in an easy and consistent manner. This workshop will show you how to utilize rbenv, bundler, and grunt.js to create a simple and easy workflow for your team. It is guaranteed to take the pain out of the Sass development process, and allow your developers to do what they do best: develop.
Conference Slides
-
0:00
[BLANK_AUDIO]
-
0:05
My name is Ian Carrico.
-
0:07
I'm a backend and frontend developer at Four Kitchens
-
0:09
meaning I write backend code for my frontend developers.
-
0:14
Lots of drupal work.
-
0:15
My drupal user name, if you use drupal.
-
0:18
On Twitter I am iamcarrico, on the GitHubs and the rest of the internet,
-
0:22
I am ChinggizKhan, because I like making sure that people can't spell my usernames.
-
0:27
[LAUGH] so,
-
0:29
first of all who here is Ruby developers?
-
0:37
Two. [LAUGH]
-
0:40
>> No love for Ruby? >> What?
-
0:41
>> No love for Ruby?
-
0:43
>> Who here realizes that Sass is Ruby? [LAUGH] Okay, we're good.
-
0:49
Love Ruby.
-
0:49
Love it.
-
0:51
so, one of the biggest pains of working with Sass is
-
0:55
the fact that it's Ruby, and Ruby is weird,
-
0:59
especially if you're used to other program languages or worse.
-
1:02
If you're a frontend developer and
-
1:03
don't really understand programming languages like this.
-
1:06
So Ruby has many, many versions in it. So, all of
-
1:13
Macs right now have 1.87 p something, something, something.
-
1:21
And each one of those have small changes in them.
-
1:24
Each Rubygem that comes out are updated by their own maintainers,
-
1:28
and each one of those have their own versions number in there.
-
1:31
And for example, if you use Breakpoint Breakpoint version one
-
1:36
and Breakpoint version two are not compatible with each other.
-
1:40
So if you're working with Breakpoint version one and you update,
-
1:44
all of sudden all of your code is going to start breaking.
-
1:47
Like respond to, does something weird and a whole bunch of other
-
1:50
things and it's, it's weird, it's hard, and all of a sudden
-
1:54
your entire site's breaking and you're freaking out and you're supposed to
-
1:57
deploy something that day and your boss is screaming over your shoulder.
-
1:59
This has happened to me.
-
2:01
[LAUGH] It's weird.
-
2:05
The other reason why this is hard is for most people.
-
2:09
Do most people here use Macs, generally?
-
2:13
Linux is awesome.
-
2:14
On your Mac, generally people use the system Ruby.
-
2:18
Which means that it is, you have to use pseudo to update anything.
-
2:22
So which means you have to go in and pseudo-update every single
-
2:24
version of your gem, and that gets frustrating and annoying and hard.
-
2:29
And there's, you know, different Rubygems for projects.
-
2:34
You need to know which one goes where.
-
2:35
It gets very frustrating very quickly.
-
2:39
so, luckily there are ways of making this easier, a lot easier.
-
2:46
The problem is it's really painful to even set up the system to make it easier.
-
2:51
Once it's set up, everything works really great.
-
2:57
It's just the setting it up is hard.
-
2:59
So we're having a painful morning to make all of
-
3:01
the Sass developments open in the future so pretty much,
-
3:04
much, much easier.
-
3:06
So first of all the easiest thing you can do is type in to your command line if
-
3:12
you're using a Mac, this command echo 'gem: NO-RDOC.
-
3:18
>> Does it have to be all caps like that?
-
3:21
>> [LAUGH]
-
3:24
>> Actually no. The gemrc should be lower-case.
-
3:30
This
-
3:32
what happens when I use slides, on the internet.
-
3:36
So what this does is, every time you install new
-
3:38
gems, it will not install a documentation along with it.
-
3:43
Which means that your gem installation time
-
3:44
will go from five minutes to 30 seconds.
-
3:47
[LAUGH] I'm still not entirely certain why we have to
-
3:51
have all the documentation there, but it's lots of no fun.
-
3:55
This is the quickest and dirtiest thing you can do.
-
3:57
[BLANK_AUDIO]
-
4:11
We got it? Kay.
-
4:13
>> Is my command line supposed to tell me anything?
-
4:15
>> No. >> Okay.
-
4:16
>> [LAUGH] So all this is doing, it's creating
-
4:19
your within your home directory, a file called gemrc.
-
4:23
Which has your gem settings in there.
-
4:24
And then this line right here tells your gem,
-
4:28
your gems, to not download the rdoc or the ridocs.
-
4:32
Which is your documentation when it downloads a gem.
-
4:35
So,
-
4:36
the easiest little thing solves everyone's problems so quickly.
-
4:41
Second thing, okay.
-
4:44
So this is the portion of the presentation which
-
4:48
you may or may not want to actually do.
-
4:52
As I said Ruby has many versions.
-
4:55
One of the ways of solving for that is by installing a Ruby version manager.
-
5:00
There are three
-
5:01
of these that I know of. There's RVM, RBENV and
-
5:06
chruby. I have, most my Ruby friends use RBENV.
-
5:14
RV, RVM is more common in tutorials, but it
-
5:18
installs a bunch of crap that you don't want.
-
5:21
And it's far more of a system than you will ever need.
-
5:26
The problem with
-
5:26
RBENV is it's really hard to install, unlike RBN.
-
5:29
But once it's installed, it's far easier.
-
5:34
So who here who's using a Mac has Homebrew installed already?
-
5:40
Fantastic for you all, this is the easiest thing in the world.
-
5:44
For those who do not have Homebrew installed,
-
5:48
it's documented online. >> [LAUGH]
-
5:51
>> There's actually a lot of great tutorials
-
5:54
I'm not gonna go over today and you guys
-
5:56
can kind of take a nap and go on Facebook for five minutes while I explain this.
-
6:01
It's not needed to use RBENV. It's definitely useful if you
-
6:07
are going to be using different versions of Ruby it's needed.
-
6:12
If you are just doing
-
6:13
Sass developments, and you're a frontend developer, I would say don't do this.
-
6:18
Ignore these next five minutes.
-
6:19
Yes?
-
6:20
>> Is this, like, a, a way to sort of localize all your Ruby stuff?
-
6:23
Does this keep projects separate, all your versions and all that?
-
6:26
>> So this is a way it will
-
6:27
install different versions of Ruby into your home directory.
-
6:30
So that means, one, you can install gems without needing Pseudo.
-
6:34
and, two, it means that if you have one project
-
6:39
with Ruby 1.8.7, and the other project was Ruby 2.0.
-
6:44
You can keep those separate and it will
-
6:47
maintain which versions of Ruby you're actually using.
-
6:49
So, why should you not use system Ruby
-
6:53
if you're not using a different version of Ruby?
-
6:57
This is a fun one.
-
6:58
The next version of OS X is not going to
-
7:00
be using the same version of Ruby you're using now.
-
7:03
[SOUND] Yeah, lots of fun. Lots of fun.
-
7:08
It's going to upgrade to Ruby 2.0 as opposed to 1.8.7.
-
7:13
1.8.7 was the current, was a very, very stable branch.
-
7:17
Now, 2.0 is, so they're using that.
-
7:20
For most Sass development, this shouldn't matter.
-
7:23
Much.
-
7:24
[LAUGH] Much. There are
-
7:28
some things that might happen in Compass that
-
7:30
will require 2.0, but that won't happen for another
-
7:33
year at best because it needs 2.0 and
-
7:37
not everyone should be upgrading it because it's weird.
-
7:41
[COUGH] so, we allowed different versions of Ruby.
-
7:44
But, Ruby installs into your user directory.
-
7:47
Requires Homebrew.
-
7:48
So if you don't have Homebrew, you'll need this to install RBENV.
-
7:52
You can do this at home
-
7:53
later, if you want, you don't need to do it right now.
-
7:57
If you do have RB Homebrew installed make sure you
-
8:02
do a brew update so that you have the latest brews.
-
8:07
I don't know what to actually call them. [LAUGH] And then you just type in brew
-
8:12
install RBENV and ruby-build, and this will install RBENV, and the same developer
-
8:18
has a another Homebrew called ruby-build that will build different
-
8:24
versions of Ruby for RBENV, so it will allow you to quickly install.
-
8:30
[BLANK_AUDIO]
-
8:34
You already have RBENV? >> Yeah.
-
8:37
>> Nice.
-
8:38
Well done. Why are you even here?
-
8:40
You, you've got this! >> [LAUGH]
-
8:46
You might want to reinstall it depending on when you installed it.
-
8:50
The most recent version has version two, ruby version 2.0.0-p247.
-
8:59
>> [UNKNOWN] >> 030?
-
9:02
I mean the Ruby version.
-
9:03
>> Oh.
-
9:04
>> Which I started using just because it's what the next version of what
-
9:08
the OSN will use and I'd rather start testing in advance, just in case.
-
9:15
So the other thing you have to do, if you're using Mac, once you install RBENV,
-
9:19
you run echo, eval, that stuff, bash_profile.
-
9:25
And what that does is on, when you turn on the
-
9:29
terminal, make sure you're actually using RBENV instead of system Ruby.
-
9:36
I thought people pause more doing this.
-
9:39
Feel free if there's any questions throughout this.
-
9:42
Don't look at me with confusion, just ask.
-
9:44
>> I thought I saw something on Twitter about Compass, about
-
9:48
Ruby 2 like not being compatible with Compass due to some dependencies.
-
9:54
Do you know something about that? >> There shouldn't be.
-
9:57
I've been using Ruby 2 for the past three or four months,
-
10:02
and I haven't had any issues.
-
10:03
>> I think it is something Bryan Jones tweeted out.
-
10:06
Saw him and Chris have some exchange. I'll ask Chris.
-
10:09
>> I'll, I can ask Chris afterwards, but as, as far as I know,
-
10:11
there are some things that will improve Compass if Ruby 2 is used more often.
-
10:19
And it's mainly the listen functionality.
-
10:22
That can be improved dramatically if we can use Listen 2, which requires Ruby 2.
-
10:28
But yeah, I, I can talk to Chris.
-
10:29
Nice thing about this is you can install whatever versions you want.
-
10:32
So I do have installed on my system
-
10:35
1.8.7 and 2.0 for, in case something bad happens.
-
10:39
I haven't had anything bad happen so far.
-
10:42
>> Just if for some reason you're using Drupal Aurora.
-
10:45
Yeah.
-
10:46
>> Grunt's tag, this is just irrelevant to that or does this help that?
-
10:50
Helps that.
-
10:51
>> Helps that? >> Helps that.
-
10:53
This is purely Ruby, although the Grunt stack is
-
10:55
the very last thing we're going to go over.
-
10:57
Love me some Grunt.
-
10:59
Okay.
-
11:01
Can I click it?
-
11:03
Actually, I'm going to pause quickly and do this as well.
-
11:07
I forgot, I also should tell you all this.
-
11:13
If you go there, bitly.com or bitly/painfulSass.
-
11:19
This has my slides, as well as example files.
-
11:23
[CROSSTALK]
-
11:26
What?
-
11:26
>> Yeah there we go. Yeah, I keep everything on the GitHubs.
-
11:31
And it will be there forever and ever. Amen.
-
11:35
>> [LAUGH]
-
11:39
>> So yeah, painfulSass.
-
11:43
It has all these commands so you can copy and
-
11:44
paste them as well as example files that we're gonna use a little later.
-
11:53
Okay. So once you
-
11:58
have RBENV installed, to install a new version of Ruby all you do
-
12:01
is RBENV install and whatever version of Ruby you want.
-
12:07
So the example here is the version that will be on OS 10
-
12:12
2.0.0-p247.
-
12:18
That will take a few minutes to run. So this is
-
12:23
fun throughout this workshop.
-
12:24
Half of the time it's just sitting there watching your computer think.
-
12:28
Then you run RBENV rehash, and that just, RBENV will make
-
12:32
sure that it has all the right files in the right place.
-
12:36
And you can set RBENV global to the same
-
12:39
version that you're installed and that will make sure that
-
12:44
every time you run Ruby files in the command line,
-
12:46
it will always use the verse that you just installed.
-
12:48
Version is just set there.
-
12:50
>> Does it work like IBM that if you change
-
12:52
that then you've got a different gem set or different gem?
-
12:56
>> Yes, so, the big difference between RBM
-
12:59
and RBENV is that gem sets don't technically exist
-
13:02
in RBENV.
-
13:03
>> So if I installed gems while I was using one nine whatever
-
13:07
>> You have to re-install them for the second version.
-
13:11
Which is, slightly annoying.
-
13:15
At the same time it's really beneficial to make sure that
-
13:18
you do keep things separate and have the right versions and everything.
-
13:22
>> Do you have a quick way to like,
-
13:24
save that reference, the gems here just install the
-
13:27
same ones, even though.
-
13:29
>> I don't know of a quick way to do that.
-
13:31
I, I could think of a way of changing your gem path
-
13:34
to be in the same place, but that starts getting weird very quickly.
-
13:45
We're typing.
-
13:45
I'm gonna, unless someone yells at me I'm gonna move on.
-
13:50
Okay. So, Ruby version.
-
13:53
If you weren't paying attention before because you
-
13:55
don't want RBENV, come back to me now.
-
13:57
This is where we need to start paying attention again.
-
14:00
so, there is a file in all your projects that should be there called .RUBY-VERSION.
-
14:09
And what this is,
-
14:10
is it tells the project what Ruby version you're using, which is kind of important.
-
14:16
So if you are using RBENV, if you're using RBM, you're using CHRuby or if you're not
-
14:22
doing this at all, you should include this file so you know which version of Ruby.
-
14:26
>> [COUGH].
-
14:26
>> You started the project with.
-
14:28
And it will always just go if you have this file and
-
14:32
you are using RBENV it will always use the version of Ruby that
-
14:35
is saved in this file. So, all this is, is just a simple text
-
14:40
file called .ruby-version that just has the version number.
-
14:46
That is it.
-
14:48
If you look at my GitHub, you can see there's an example one in there.
-
14:51
So 1.8.7-p358. That is what is in OS X currently.
-
14:58
This is what's gonna be in the next version of OS X.
-
15:00
It's
-
15:01
10.9. Who knows what's gonna happen after that?
-
15:05
We're gonna have OS, X 11 no, it would
-
15:11
be a branding nightmare.
-
15:15
So doing this will allow people who are using any
-
15:19
sort of version management for Ruby to use the correct version.
-
15:24
And so that in the future, in case something changes,
-
15:27
you can go back and know, crap, it might have
-
15:30
been a Ruby issue, let me make sure I have
-
15:32
that exact version of Ruby to make sure everything's going okay.
-
15:37
>> Would you recommend the file [COUGH] goes on with production
-
15:40
environments as well if you're working, like, with distributed jump by staging.
-
15:45
>> Might as well.
-
15:46
It can't hurt to have it in there.
-
15:48
I mean its no different than having a getIgnore file in production.
-
15:50
It doesn't actually give any real information about the project anyway.
-
15:54
But yes, I would say, this should be in version control.
-
15:58
This should be where everyone can access it, cuz if you do have
-
16:01
something running on production, for example, you
-
16:04
want to make sure that they're using
-
16:05
the right version of Ruby. [SOUND]
-
16:11
>> So does the RBENV read that file or does something that loads your code?
-
16:16
>> so.
-
16:17
>> Or does it, is it functional or does it?
-
16:19
>> It is functional.
-
16:20
RVM, CHRuby, and RV all read that file when they're running something.
-
16:25
So, if that file is there, they will reference that first
-
16:30
and then, and then they'll reference your global if that file doesn't exist.
-
16:35
If you're using RBENV you can also just type in RBENV
-
16:38
local and your version number and that'll create the file for you.
-
16:46
Okay, that's. RBENV.
-
16:50
It's kind of weird.
-
16:52
I know, this whole thing is weird. I'm sorry.
-
16:57
Anyone have any questions about, like, why you should have RBM or benefits of it?
-
17:04
Anyone looking confused?
-
17:08
>> I, I, I think you may have just asked this, but I just want to clarify.
-
17:12
So that.
-
17:13
When does it get?
-
17:14
like, how, how does this version get switched?
-
17:20
>> So, depending on which if you're using
-
17:23
RBENV RBENV will it does some weird things
-
17:27
in your system, where, if the, I forget
-
17:30
the, the exact term, but when you run Ruby,
-
17:33
it actually runs RBENV.
-
17:35
And RBENV selects which version of Ruby you should actually run against.
-
17:38
>> Based on the gem, you kind of. >> Yes.
-
17:40
Based upon either your global setting or the Ruby version file in your
-
17:46
project directory. So I started using RBENV for two reasons.
-
17:52
One testing because since I manage sometimes extensions I want
-
17:56
to actually make sure it does work on different versions.
-
17:59
And two, it just makes my life easier if I'm not using system Ruby.
-
18:04
So much easier.
-
18:07
so, the second thing you need RBENV manages your Ruby,
-
18:10
now we need something to manage all of our gems.
-
18:14
And gems include Sass is a gem, Compass is
-
18:17
a gem any of Compass extensions are all gems.
-
18:22
Many of your Compass extensions are not always
-
18:24
backwards compatible.
-
18:27
Namely, the break point singularity. Not backwards compatible.
-
18:32
Cuz there's just so much development that happens on
-
18:34
them, it's very, very difficult to keep backwards comparability.
-
18:39
Aurora's gem isn't backwards compatible.
-
18:41
>> Neither is Early Suzy. >> Neither is Suzy, Early Suzy.
-
18:46
yeah. So, bundler's a Ruby
-
18:52
gem in and of itself, that will manage your Ruby gems for you.
-
18:56
So, once you install a version of Ruby op.
-
19:05
You just do, gem install bundler.
-
19:07
If you're using system Ruby you do have to use sudo.
-
19:09
How, how can I check a version on bundler to see if I have it?
-
19:14
>> Check the version of bundler or check the version of a gem?
-
19:17
>> Of bundler.
-
19:20
>> If you type in bundle//version, it'll say you have it or not.
-
19:26
>> Okay, cool.
-
19:27
>> Yeah, and as long as you have it you're golden.
-
19:31
>> I just wanna.
-
19:33
Like it's working for me for reals, but not if I do bundler.
-
19:37
>> Not if you type in bundler?
-
19:39
>> Mm-hm.
-
19:40
>> Bundler registers the command bundle, not bundler.
-
19:46
Yes, of course. >> Because that makes sense.
-
19:48
>> Exactly.
-
19:51
I'm fairly certain that Ruby developers are out there just to make my life hell.
-
19:54
>> It was why Ruby was invented, right? >> Sorry, you two.
-
19:59
[LAUGH] Okay.
-
20:04
So now that you do that, bundler's ready to use.
-
20:07
All you need.
-
20:08
It's glorious.
-
20:11
So what bundler does is, in a project directory you can create a gem file,
-
20:16
and a gem file just has a list of all the gems that you're using.
-
20:21
And then you run bundle install.
-
20:24
And it will install of your gems from that gem file and create a Gemfile.lock.
-
20:30
The Gemfile.lock takes all those gems that it downloads,
-
20:34
and well, the Gemfile can say, we need at
-
20:36
least version 12 of Compass.
-
20:38
We need at least version one of Sass, what have you.
-
20:43
Gemfile.lock saves the exact version that it's using of every
-
20:47
single gem, and if both of these are saved in
-
20:50
version control that means I can start a project, create
-
20:53
my Gemfile, create my Gemfile.lock, and have the exact version numbers.
-
20:57
And my co-worker can start the project and run bundle install on his computer, and
-
21:01
it will download the exact same versions of each gem that I was using.
-
21:07
In a local directory?
-
21:09
Or? >> We'll get to that in a second.
-
21:11
>> [LAUGH] What, sorry what if it's installing
-
21:14
like a newer version than you've already got?
-
21:17
>> so, if it's installing a newer version I've already got
-
21:19
it will not install a newer version if I have the Gemfile.lock.
-
21:23
But if I'm just using the Gemfile it could, and it will save that information
-
21:26
in the Gemfile.lock or whichever version I have.
-
21:30
So, an
-
21:33
example Gemfile. I'll head back over here.
-
21:40
Say, don't worry about copying this.
-
21:45
It's all in the one, it's all in bundler's
-
21:47
documentation, and two it's all on that GitHub repo.
-
21:51
But it's really simple.
-
21:53
You just have a source so I use
-
21:56
RubyGems.org, cuz that's where all my Ruby gems are.
-
22:00
And then, command gets gem, the compass the gem name, comma,
-
22:05
and whatever version it needs to be. So, you have
-
22:11
this little tilde arrow. It says it needs to be at least version
-
22:19
was it 0.12, but no more than version 1.
-
22:24
Or, where it comes to Aurora, it needs to be
-
22:26
at least version 3, but it cannot be version 4.
-
22:29
So it can be 3,
-
22:30
3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, not four.
-
22:37
>> And not lower than what's specified?
-
22:39
>> And not lower than what's specified, yes.
-
22:42
You can also have exact versions of your gem file.
-
22:47
For example, I had some GitHub things on here.
-
22:51
GitHub now has actually made this even easier for me.
-
22:53
They have a gem that just does this.
-
22:58
But it's really simple.
-
23:02
So this is a optional thing, sort of.
-
23:07
If you're using system Ruby, you have to do this.
-
23:11
If you're using RBENV, you don't technically have to do this.
-
23:15
But you can if you want to.
-
23:17
So you can install you can have all
-
23:20
of your gems installed to your project directory.
-
23:23
So you have the exact version of each gem in that directory you're using.
-
23:27
If you have just a couple of projects, I kinda prefer this,
-
23:29
because it means that everything I'm using is all in one little directory.
-
23:34
My, everything.
-
23:37
but, and if you're using system Ruby, you have to do this, because
-
23:41
you don't want to have to go in and pseudo-install every single gem version.
-
23:47
And I'll say why you have to do that in a second, but you have to
-
23:53
make the directory.bundle, and I don't know why
-
23:56
this is capitalizing everything, that should not be capitalized.
-
23:59
[SOUND]
-
24:00
[BLANK_AUDIO]
-
24:08
So we want to run make directory.bundle all lowercase.
-
24:13
Silly style sheets.
-
24:16
Actually.
-
24:18
>> Can't you do like a. >> No, it's cuz it's an H4.
-
24:21
Yeah, I was told to make sure that my slides were really big.
-
24:24
So I just did header for everything as opposed to, I don't know, knowing CSS.
-
24:30
>> [LAUGH]
-
24:30
>> If only someone here new CSS. >> I know,
-
24:33
right? I'm sorry, guys.
-
24:34
I really am a frontend developer. >> [LAUGH]
-
24:38
>> Okay. So what this is, is creates in your
-
24:43
home directory there we go that's the command.
-
24:49
It creates a directory in your home directory
-
24:52
called bundler, which all your bundler settings goes into.
-
24:55
And then, this will create a file called,
-
24:58
bundle config.
-
24:58
And then this line will say, to put all of your gems into vendor/bundle.
-
25:08
So in your directory, you'll have, all
-
25:11
your Sass files then one file called vendor,
-
25:14
and in that vendor file, the bundle folder,
-
25:16
that will have all of your gem information.
-
25:22
So I'll leave that up for a second.
-
25:24
[BLANK_AUDIO]
-
25:29
Should probably mention. Yes.
-
25:30
>> How does, how does Ruby, or RBM [COUGH] know about vendor/bundle?
-
25:36
>> Ruby does not, bundler does. >> Okay.
-
25:39
>> Hm. >> I love questions.
-
25:42
They're, just, like, hold on, just wait two minutes.
-
25:45
But no, that's a great question.
-
25:47
I should probably mention that all of this comes out of
-
25:51
Four Kitchens, the the company I work for has no Ruby developers.
-
25:55
So when we started using Sass, we started running into huge issues
-
25:59
very quickly and spent months trying to figure out, what is this doing?
-
26:04
And you have to like go into Ruby documentation to figure that out.
-
26:07
Tsk, tsk, tsk, okay.
-
26:09
>> And should we do this for every project that we initiate?
-
26:12
>> So, this is a onetime setting. Okay, so it's in your home directory.
-
26:15
Once it's done, it's done.
-
26:18
The only thing that's per project that we've done so
-
26:20
far is the Ruby version file.
-
26:23
Everything else is just a setting that happens and you, your done.
-
26:26
>> Just make sure everyone on the team uses bundler?
-
26:28
>> Yes, and they should be. Trust.
-
26:32
>> You can probably do a lot of, you know,
-
26:33
have a script or something that does all these things.
-
26:36
[CROSSTALK]
-
26:39
>> Yeah.
-
26:40
You could have vagrant do something or, and there's
-
26:43
a bunch of things that could just create a script.
-
26:47
Let me find it.
-
26:48
So, now in your directory, all you do is run bundle install
-
26:53
and that will install all of your gems, in the right version.
-
26:58
Sometimes you might think, hey, if you're using
-
27:01
system Ruby I have to use sudo right?
-
27:05
Don't do this.
-
27:06
Never ever, ever, ever, ever run sudo bundle install.
-
27:10
This is a great way to break things very quickly.
-
27:14
the, the short explanation on why is bundler doesn't just
-
27:18
save settings to like it doesn't just download gems, it also
-
27:23
changes some local settings to your user, and if you do
-
27:26
pseudo-bundle install, it'll change it for the root user, not your user.
-
27:29
And it's weird, it's funky, but it's like big no-no.
-
27:35
Do not run sudo bundle Install. Bundle install.
-
27:41
>> Just bundle? >> Just bundle.
-
27:42
>> What if you may have run sudo bundle
-
27:45
Install in the past what symptom could you have experienced?
-
27:49
[LAUGH] Your entire computer will blow up in 30 minutes.
-
27:55
no, it, it, it's not terrible it just, it changes how bundlers should work.
-
28:00
So if you use RBENV all that issues will go away.
-
28:05
But yeah, or whenever you update your Mac the Ruby shit will change
-
28:11
>> If we bundle install now, what bundles is it going to install?
-
28:14
So, if you do this in your project directory, that's, it will
-
28:19
take a look at the gem file and install all those gems.
-
28:22
If you just do it in a regular directory, nothing will happen.
-
28:29
And now instead of running compass compile, you just run bundle exec
-
28:33
compass compile, and that will, bundler will then get all the right gems.
-
28:38
It will go to wherever your gems are stored,
-
28:40
whether it's in the local directory or the right directory
-
28:43
with RBENV, and it will use the exact versions
-
28:46
in the Gemfile.lock file to run all of your commands.
-
28:49
And now all of a sudden you don't have to go through dependency hell with Ruby gems.
-
28:58
>> So this, so one time, a one time thing?
-
29:00
>> No.
-
29:00
This is whenever you run compass compile or compass watch.
-
29:03
You just run bundle exec compass watch.
-
29:06
Yes.
-
29:08
>> So then what you're saying that avoids dependency help, but like
-
29:11
if you just use compass compile then you don't really have any issues.
-
29:15
Is it just, if you're not having issues, its cuz you're not using enough of the.
-
29:19
>> So, this is what happened to us at Four Kitchens.
-
29:23
We were using just compass compile, compass watch for months.
-
29:27
And then one of our gems that we used on pretty
-
29:29
much every one of our projects updated, and we didn't realize it.
-
29:34
So, we were just running things and all
-
29:36
of a sudden, all of our projects before broke.
-
29:41
And nothing would compile correctly, we're getting errors.
-
29:45
But if we just had our gem file and Gemfile.lock in that we knew what
-
29:50
this was, then we could just go back and say, oh, we were using this version.
-
29:54
We just run bundle exec compass watch, and
-
29:57
all of our problems are solved, and yes it's
-
30:00
very frustrating to have to write up and
-
30:01
bundle exec compass watch, but that's the next step.
-
30:05
Getting rid of even that. >> So, if I understand what this does,
-
30:10
right? >> Mm-hm.
-
30:11
>> Is it that now we're gonna use the bundle version controlled version of gems.
-
30:16
>> Yup. >> To do complex.
-
30:17
>> Mm-hm. >> Regular.
-
30:19
>> Yes.
-
30:19
>> Most recent Compass. >> Yes.
-
30:21
>> Okay.
-
30:22
>> Or whatever is most recently installed onto your system.
-
30:25
>> Okay.
-
30:25
Cool. >> Yeah.
-
30:26
>> And then if your operating singularity or whatever.
-
30:29
>> Mm-hm.
-
30:30
>> Just change the number of the gem file.
-
30:32
>> You can either change the number of the gem file or there's
-
30:36
a command, it's just bundle update singularity GS, and
-
30:39
that will then update your Gemfile.lock in your Gemfile
-
30:45
>> And this isn't just for companies to compile, this is for anything.
-
30:47
>> This is for anything with Ruby, yeah.
-
30:50
Yeah, so if, for some reason you decide that you wanna become
-
30:53
a Rails developer in the future Rails developers all use this too.
-
30:57
Mainly Ruby development.
-
30:59
It just kinda sucks that being frontend developers we kinda have to do it too now.
-
31:06
But yeah, the, the biggest thing I, if I can impress by anyone is make sure you
-
31:11
do create Gemfile, and Gemfile.lock for the day that
-
31:15
when everything breaks, you can fix it very quickly.
-
31:20
Instead of where we were, in which, I actually was like calling
-
31:23
up Sam, going Sam, what did you do to break everything I did?
-
31:28
>> Is the Gemfile.lock, isn't that auto, automatically generated?
-
31:32
>> Yes. So, yeah, you created gem file.
-
31:35
Gemfile.lock is created by bundler.
-
31:37
>> Is that gem file, is it case sensitive to the file name?
-
31:41
Or can it just be?
-
31:43
>> It is case sensitive.
-
31:44
And I believe it's, yeah. Capital G and everything else.
-
31:50
>> So the gem file is when you're developing a ruby gem?
-
31:53
>> Gem file is just in any of your project that you're using Sass.
-
31:56
Just create a gem file.
-
31:58
List the gems that you're using.
-
32:00
So if you're using, obviously, Compass, will be one of them, Sass
-
32:04
will be one of them and then any other Ruby extensions you're using.
-
32:08
So, Compass, Breakpoint Singularity Toolkit Aurora, love me some Aurora.
-
32:18
And all of the non-Drupal developers looking a bit confused.
-
32:21
>> One more thing.
-
32:23
>>
-
32:23
Yeah.
-
32:24
>> I hope you didn't say it while I was out.
-
32:26
I'm using in a project a lot of start up scripts which include all those commands,
-
32:33
like or write the a script server, a script compile and stuff like that.
-
32:38
>> Mm-hm.
-
32:39
>> Integrate the files on things and take care of,
-
32:41
every time the server is started the bundle command, this command.
-
32:46
>> Yeah.
-
32:46
>> Because, sometimes people
-
32:48
really forgot to do this and people who are all the development takes longer.
-
32:55
I don't care about this.
-
32:56
[LAUGH] It's basically from problems about people who don't know about relief.
-
33:00
>> Mm-hm.
-
33:00
>> And [SOUND] the rehash is just one
-
33:04
command, type and script server, and you're done.
-
33:07
>> Yeah.
-
33:08
yeah. So, what we do for that is
-
33:14
we use Grunt.js. Who here knows what
-
33:19
Grunt.js is? Fantastic.
-
33:23
This is, this is my favorite part. so, Grunt.js is I forget
-
33:28
the exact term they use, it does simple tasks for you.
-
33:35
So you can create, it runs off of Node.js if you're familiar with that, so it's all
-
33:39
JavaScript based.
-
33:41
And it will run a bunch of tasks every time that you want it to.
-
33:46
So we had projects where Grunt.js runs all our bundles and all our bundle
-
33:51
execs, all our compass compile and will do all of our Watt tasks for us.
-
33:56
And we also have like a deployed task that it does, which it will do all that.
-
33:59
It will lint all our job description, it will lint
-
34:02
all our CSS, it will minify all of our images, and
-
34:04
it then it will compile all our Sass in compressed
-
34:08
form, and then we can commit that to our master branch.
-
34:12
So it's kind of like a, a wonderful, magical tool that saves a lot of time.
-
34:18
Per usual, kinda sucks to start.
-
34:21
[LAUGH] Luckily, grunt is a lot easier than it looks in the first place.
-
34:26
So, you have to install node.js on your computer, which there's
-
34:30
a helpful installer online.
-
34:32
Just go to the node.js site, download it, install it, easy as pie.
-
34:38
Compile your Sass and more. >> [INAUDIBLE]
-
34:45
>> Bower and Grunter, two completely different things.
-
34:51
So, Bower is a frontend package manager.
-
34:54
And that
-
34:55
will, download any frontend dependency that you need.
-
34:59
Grunt just does tasks.
-
34:59
>> Just does the tasks.
-
35:01
>> Yes. [SOUND] so once you have Node installed
-
35:08
you can go to the Grunt documentation for this
-
35:13
as well, but it's just NPM install with one or two G
-
35:19
>> [BLANK_AUDIO]
-
35:24
Does node just like in brew, just install node?
-
35:28
>> So the dash?
-
35:29
Okay.
-
35:30
>> [INAUDIBLE] No, I guess you know it, but I guess you need Afghan for Grunt.
-
35:36
>> Yeah, but isn't MPM?
-
35:38
>> Mpm is bind to the node now.
-
35:41
so, again, you can take a look at the documentation for this.
-
35:45
Don't worry if. >> Errors happened.
-
35:49
>> Errors happened? >> Yeah, I get the same one.
-
35:52
>> You probably have to run it in sudo.
-
35:55
>> Yeah, run it in sudo. >> Oh, okay.
-
35:58
[LAUGH] Every, every time that I run MPM install I run sudo, pretty much.
-
36:05
[NOISE]
-
36:05
>> Do you have these slides posted somewhere online?
-
36:08
>> Yes.
-
36:08
>> Yeah? >> Yes.
-
36:09
Yes, they are.
-
36:09
[BLANK_AUDIO]
-
36:19
So things that Grunt.js can do, once, once you have it installed.
-
36:24
Can do livereload for you, magically.
-
36:26
You can do it on your server, so if you are developing on a
-
36:29
development server you can have a livereload
-
36:31
run over here and still work locally.
-
36:35
Yeah, that's by far the coolest thing it does.
-
36:38
Image minification, so it will take all of
-
36:40
your images and optimize them without loosing any quality.
-
36:45
You can easily save 30, 40% of image size just by running that.
-
36:51
JavaScript linting, JavaScript minification, Jekyll integration
-
36:54
if you use that et cetera.
-
36:56
It can really do anything.
-
36:58
I'm gonna be working this afternoon to see if I
-
37:00
can get some more Ruby stuff built in with it.
-
37:04
oh, I was skip the end.
-
37:07
So, here's my example on what Grunt
-
37:10
can actually do. Let me make this bigger.
-
37:18
I, in this directory, I have an example of gruntfile.js.
-
37:22
You can look at it.
-
37:23
I also have more examples on the GitHubs. But all I do is run Grunt.
-
37:30
[BLANK_AUDIO]
-
37:36
And now it's running my watch task. And I can go over to my Sass file.
-
37:41
Actually let me do this.
-
37:42
This, this is my webpage.
-
37:44
As you can tell I spent a lot of time on designing it.
-
37:47
>> [LAUGH]
-
37:48
>> But I can take a look at my
-
37:50
Sass file which has background color gold on it.
-
37:56
I'm just gonna refresh this quickly just to make sure it's running.
-
37:58
And I'm gonna change the background
-
38:01
color, green. Save.
-
38:06
And wait. There we go.
-
38:09
And it's green. >> Linting and.
-
38:13
>> Yeah.
-
38:14
So, this is what, for those of you who
-
38:15
are not familiar with livereload, it will, as you compile
-
38:20
your Sass, it will then push the assets to your
-
38:23
webpage and update the assets on your side without refreshing.
-
38:28
So like, if you're styling this thing within
-
38:31
a field group that is, like, three down, midway through the page,
-
38:34
you don't have to refresh the page and go back down every time.
-
38:37
It just does it.
-
38:39
It's magic.
-
38:41
I once tried to look at the script and
-
38:43
said, it's magic, I'll just leave it at that.
-
38:47
>> What if you get a linting error, how does it
-
38:50
>> So, if you get a linting error it will actually
-
38:52
just say, here linting error, and you can decide whether or not
-
38:56
you want that to actually stop compling.
-
38:59
>> Oh so, it'll, it'll flip through the command
-
39:01
line you have and say, no, I got it.
-
39:02
Yeah so, yeah I've had projects where like for deploy, it's strict.
-
39:09
It will not let you deploy without having full js linting, but during
-
39:13
development, it'll say, eh, you might wanna
-
39:15
fix this, but it'll still do everything.
-
39:17
So to give you an idea how easy it is actually work with Grunts
-
39:24
besides the fact that it's JavaScript, which is
-
39:25
weird this is all of the commands I need,
-
39:29
and this will do all of my optimization,
-
39:33
all of my minification, all of my Compass stuff
-
39:39
and a bunch of other things. And again, this example is online.
-
39:42
This is a simple one. But this also runs bundler, by default.
-
39:48
So you can see in my compassing bundleExec is true.
-
39:54
That even bigger.
-
39:57
So this means that instead of having to run
-
39:58
bundleExec compass compile every time, I just run Grunt.
-
40:03
And Grunt then handles my
-
40:04
compass watch. It handles my bundler stuff.
-
40:07
It handles all of my right versions for everything.
-
40:10
And it just does it.
-
40:12
This is, by far, the most useful thing I have ever learned in
-
40:16
the past year, because it means that I don't have to do anything.
-
40:19
And as with everything, we set it up once for project, which really
-
40:23
is we copy and paste the last project's Grunt file, and that's it.
-
40:29
And then
-
40:29
all of our developers are always using the right versions of all
-
40:31
our gems, all of our frontend developers don't have to do anything.
-
40:36
It's just simple and easy so, it goes from freaking out because
-
40:41
I don't have the right version of Ruby, my gems are freaking out to one command.
-
40:47
That's, that's the least pain I can give you.
-
40:49
As I said, it takes a lot of pain to get
-
40:52
to that point, but once you do, it feels so good.
-
40:58
So is anyone here, Drupal developers, Drupal developers?
-
41:03
Yeah, so [LAUGH] I'm, I'm a Drupal developer.
-
41:08
I love pain.
-
41:09
Love Drupal. >> [LAUGH]
-
41:13
>> Yeah.
-
41:13
So, the Aurora theme, has a Compass
-
41:15
extension that creates your sub-theme for you.
-
41:17
It also has Grunt integration built into it.
-
41:20
So if you go to Aurora documentation, you just run
-
41:23
it's like Compass installed of Aurora Grunt something.
-
41:27
It's a command.
-
41:29
It's, it's on the docs.
-
41:29
I always forget what it is and copy and paste it myself.
-
41:32
And that will install all of your Grunt integration for you.
-
41:35
It'll have a full Grunt file that we maintain for you.
-
41:39
And it, that also includes the livereload stuff.
-
41:41
So if you're using Aurora or the Magic Module on
-
41:44
Drupal livereload is just a setting that you turn on.
-
41:47
And it will handle all the JavaScript
-
41:49
for you. [SOUND] [CROSSTALK].
-
41:53
Yeah.
-
41:54
>> What in? One question.
-
41:56
actually, running that. If you kill the watch.watch.
-
41:59
>> Mm-hm.
-
42:00
>> Does it release the library load port?
-
42:02
>> It does. >> It does?
-
42:03
>> It should.
-
42:05
>> And if it doesn't? [LAUGH]
-
42:06
>> [LAUGH] >> You have other issues.
-
42:09
>> [LAUGH].
-
42:10
>> And all of the stuff that you're doing in like Sass, are you
-
42:14
just doing it like command and coalesce it and you're like editing
-
42:17
it and then as you save it, it saves a back up?
-
42:19
>> Mm-hm.
-
42:19
>> To your server. [CROSSTALK] Yep, yep.
-
42:23
>> Are you aware, I ran into issues that, if you had in that config
-
42:28
outlay, if you had a require, like. >> Mm-hm.
-
42:33
>> Sudo, in this case do you have, is that what
-
42:36
you put or is that just how the gem file config?
-
42:40
>> No.
-
42:40
You, you still have to have it in your Configure OB file.
-
42:42
>> Have you done a config OB that has more than one require?
-
42:45
>> Yeah.
-
42:46
>> And you haven't run into issues with Grunt.JS?
-
42:48
>> Hm-mm.
-
42:50
>> Okay.
-
42:50
Cuz I have problems with if I had more than
-
42:53
one, you had to, like, use the raw part of
-
42:57
>> Interesting.
-
42:57
>> The office.
-
42:58
He couldn't make it one of the options for Compass' raw [INAUDIBLE].
-
43:01
>> Yeah.
-
43:03
>> Because I have more than one.
-
43:05
>> That's weird.
-
43:06
I have not seen that before, but I'd be interested
-
43:08
in checking that out, seeing what could be causing that.
-
43:11
>> Yeah.
-
43:13
>> We actually had a very similar issue in my company where
-
43:16
it was, it was actually happening [INAUDIBLE] where, so our assets are
-
43:22
grouped in a sub-directory that's not part of our project directory, and
-
43:25
so because we were running Grunt from the project directory, it didn't work.
-
43:29
It's there was like a lot new expectations within
-
43:32
Grunt to then get Compass to run within the sub-directory.
-
43:35
And we, when we were able to figure
-
43:37
all that out, it solves those problems, actually.
-
43:39
>> Yeah, I actually. >> Yeah.
-
43:39
>> Actually, since resolving those same issues, I
-
43:42
haven't had a chance of putting an app [CROSSTALK].
-
43:45
>> Oh, sorry.
-
43:45
>> I think the issue I had was before I resolved those ones.
-
43:50
>> Oh, okay.
-
43:51
>> So I haven't tried performing another.
-
43:52
>> Mm-hm.
-
43:54
I feel like a Drupal site, if you wanna change
-
43:56
the image directory, put just sites all beams inside of that.
-
44:01
>> Yeah. so, what I do is,
-
44:03
this is all within my theme. So then all the directions are small.
-
44:08
One thing you can't see here, I actually have, in my config RB file, my images
-
44:13
directory is _img. And then in my distribution
-
44:18
it's IMG. And what this is, or why this is, is cuz
-
44:22
it will do my image minification, this is the best reason by you should be using
-
44:29
imageder and Compass, because on while I'm developing it uses
-
44:34
big versions of images, and then Grunt will minify everything,
-
44:39
put it in the image directory, and it'll automatically change
-
44:44
all of my CSS to use that directory for production.
-
44:49
Any other questions?
-
44:49
>> Yeah, sorry.
-
44:50
So you're not, you're not running a real app network, right?
-
44:53
>> Nope.
-
44:54
>> You're just running this kind of
-
44:57
separately just for your, like Sass images.
-
45:01
>> Yeah this is for, so, since we do all Drupal work.
-
45:03
This is all within my theme Drupal directory.
-
45:05
So this is all of my Compass, all of my images, Sass just frontend work.
-
45:10
And the nice thing about all these things
-
45:12
is it's not reliant on anything like Rails.
-
45:15
It's purely if you're doing WordPress, Drupal,
-
45:19
Joomla, your own thing, what have you. It applies to all of it.
-
45:25
>> I, I use Django, but I like Sass a lot, so.
-
45:28
>> Yeah.
-
45:29
One last thing, just going back to that [INAUDIBLE].
-
45:33
>> Mm-hm.
-
45:33
>> Being that sort of alias or shortcut for that longer one?
-
45:37
You're saying that, that resolves, if you upgraded one
-
45:40
of the gems, was that you're looking for using.
-
45:43
>> Yeah,
-
45:44
so if, if like in your system Ruby or, or you're base Ruby that you have
-
45:49
compass 13 or 0.13 and your project needs compass 0.12.
-
45:55
If you're, you're using bundler and using bundleExec, or a gem file
-
46:00
like this, it will always use the one two instead of the one three.
-
46:06
[BLANK_AUDIO]
-
46:09
Which, on one hand, it's like you're not
-
46:11
using the best, but you can always update it.
-
46:14
The other hand, one day, Sam [UNKNOWN] with update
-
46:17
your gem on you, [LAUGH] and everything will break.
-
46:20
>> [LAUGH] What do you think about just using the Sass, you
-
46:23
know, the source files direct, directly of whatever you want to use,
-
46:27
you know, to kind of cut that of out your equation, like
-
46:29
I use Suzy but I just said, you know, put, putting style sheets
-
46:34
in mind under a vendor sub-directory. >> I'd say you can do that.
-
46:40
and, I know, like, for Team Sass, we're trying to get
-
46:44
to a point where we're not using any Ruby on our codes.
-
46:46
But if you have a if you have a Compass extension that uses Ruby so for
-
46:53
example Compass has a lot of Ruby built into it, you would have to use Bundler.
-
46:57
But if like you're using like, the Compass normalized
-
47:01
gem, you can just copy those files. That's, that's not hard.
-
47:05
I know with the, the team Sass we're
-
47:07
trying to make it so that nothing uses Ruby.
-
47:10
I think Breakpoint still has one function in there that we have to have.
-
47:15
But that might, that should be coming out once it gets ported to Compass.
-
47:23
Any other questions?
-
47:24
>> Yeah, how, how much of this can we do on a Windows machine?
-
47:27
[LAUGH] >> So, what I need
-
47:36
you to do is go home, take that Windows machine, and put it in the trash can.
-
47:38
>> [LAUGH] >> Just kidding.
-
47:41
So bunder bundler and node all work on a Windows machine.
-
47:47
You just
-
47:48
have to get Ruby on a Windows machine and, which you'd have to
-
47:53
anyway for all of this but yeah, everything actually still works just fine.
-
47:58
I.
-
47:58
I know node.js can, but I haven't done that myself.
-
48:02
But yeah or, yeah, use, use Linux.
-
48:07
>> Yes! >> [LAUGH].
-
48:08
>> Yeah, why don't you running in a virtual machine?
-
48:12
>> Yeah.
-
48:14
[NOISE]
You need to sign up for Treehouse in order to download course files.
Sign up