Navigation Menu

Skip to content

Commit

Permalink
Go back to running all this junk with rake tasks instead of relying o…
Browse files Browse the repository at this point in the history
…n just Grunt.
  • Loading branch information
javasteve99 committed Feb 9, 2014
1 parent d1b6fc1 commit 85120d7
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 42 deletions.
35 changes: 21 additions & 14 deletions README.md
@@ -1,42 +1,49 @@
# Static Site Starter

A skeleton for quickly starting a new static site. It uses [Grunt](http://gruntjs.com/) to run all of the following tasks: [Jekyll](http://jekyllrb.com/) to generate static pages and run a web server, [SASS](http://sass-lang.com/)/[Bourbon](http://bourbon.io/) to facilitate rapid CSS, and Grunt concatenates and minifies JS files, compresses images and reloads the browser when changes are detected.
A skeleton for quickly starting a new static site. It uses [Grunt](http://gruntjs.com/) to concatenate and minify JS files, compress images and recompile assets when changes are detected, [SASS](http://sass-lang.com/)/[Bourbon](http://bourbon.io/) to facilitate rapid CSS, and [Jekyll](http://jekyllrb.com/) to generate static pages and run a web server.

## Installing Dependencies

You need to have Ruby and Node JS installed for the dependencies to work. If you're running OSX you most likely have Ruby installed already. If not, or if you need the latest and greatest, go [here](https://www.ruby-lang.org/en/downloads/). Installers for Node JS can be found [here](http://nodejs.org/download/).

### Installing Jekyll & SASS using Bundler:
### Installing Grunt:

```shell
npm install -g grunt-cli
```

### Installing Jekyll, SASS & Grunt modules the easy way:

```shell
cd static-site-starter
bundle install
rake install
```

### Installing Jekyll & SASS without Bundler:
### Installing Jekyll, SASS & Grunt modules individually:

```shell
cd static-site-starter
gem install jekyll
gem install sass
npm install
```

### Installing Grunt:
## Watching files and running a server for development

```shell
npm install -g grunt-cli
rake serve
```

### Installing Grunt modules:
This will run a server for the project that can be accessed at [http://localhost:4000](http://localhost:4000). Changes to files will tell Jekyll/Grunt to automatically rebuild the site. Grunt will also run and compile SASS to CSS, compress images, compile/minify JS and compress images when it detects changes to any of these types of files.

```shell
cd static-site-starter
npm install
```
FYI, Grunt and Jekyll don't play nice together sometimes, especially upon initial startup of the server. You're likely to see an unstyled page because the site has been compiled before the assets could be. Just change something and the resulting recompile should make everything fine.

## Watching files and running a server
## Just building the site

```shell
grunt
rake build
```

This will run a server for the project that can be accessed at [http://localhost:4000](http://localhost:4000). Changes to files will tell Jekyll/Grunt to automatically rebuild the site. Grunt will also run and compile SASS to CSS, compress images, compile/minify JS and compress images when it detects changes to any of these types of files.
If you're just looking for a quick static build of your project files this will run Grunt to compile all assets and then build the site to the /_site directory with Jekyll.

This doesn't seem to suffer from the uncompiled assets problem that running a server does because Jekyll specifically doesn't compile until Grunt has finished.
25 changes: 25 additions & 0 deletions Rakefile
@@ -0,0 +1,25 @@
desc "Installs all dependencies."
task :install do
puts "Installing dependencies"
system "bundle install"
system "npm install"
end

desc "Runs Grunt to compile assets, compiles Jekyll site."
task :build do
puts "Running Grunt tasks and compiling Jekyll site."
system "grunt:build"
system "jekyll build"
end

desc "Runs Grunt to compile assets and watch for changes, starts Jekyll server."
task :serve do
puts "Running Grunt tasks and watching for changes, starting the Jekyll server."
gruntWatchPid = Process.spawn("grunt")
jekyllServePid = Process.spawn("jekyll serve --watch")
trap("INT") {
[gruntWatchPid, jekyllServePid].each { |pid| Process.kill(9, pid) rescue Errno::ESRCH }
exit 0
}
[gruntWatchPid, jekyllServePid].each { |pid| Process.wait(pid) }
end
2 changes: 1 addition & 1 deletion assets/build/css/application.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion assets/src/scss/application.scss
Expand Up @@ -34,11 +34,12 @@

[role="banner"] {
border-bottom: 1px solid lighten(black, 80%);
padding: 1em 0;

h1 {
@include heading-third;
color: $primary;
margin: 0.25em 0;
margin-bottom: 0;
}
}

Expand Down

0 comments on commit 85120d7

Please sign in to comment.