Drew Machat / @negativev / alleyinteractive.com
compass compile
compass watch
/usr/local/lib/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:135:in require': cannot load such file -- sass/script/node (LoadError) from /usr/local/lib/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:135:inrescue in require' from /usr/local/lib/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:144:in require' from /usr/lib/ruby/gems/1.9.1/gems/compass-0.12.2/lib/compass/sass_extensions/monkey_patches/browser_support.rb:1:in' from /usr/local/lib/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in require' from /usr/local/lib/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:inrequire' from /usr/lib/ruby/gems/1.9.1/gems/compass-0.12.2/lib/compass/sass_extensions/monkey_patches.rb:2:in block in' from /usr/lib/ruby/gems/1.9.1/gems/compass-0.12.2/lib/compass/sass_extensions/monkey_patches.rb:1:ineach' from /usr/lib/ruby/gems/1.9.1/gems/compass-0.12.2/lib/compass/sass_extensions/monkey_patches.rb:1:in ' from /usr/local/lib/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:inrequire' from /usr/local/lib/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in require' from /usr/lib/ruby/gems/1.9.1/gems/compass-0.12.2/lib/compass/sass_extensions.rb:9:in' from /usr/local/lib/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in require' from /usr/bin/compass:23:in'
Commonly used grunt tasks were added to the wp-starter-theme to standardize the build process, and make it easy to get started.
github.com/alleyinteractive/wp-starter-theme
Use npm install
to install the node modules you'll need to run grunt.
package.json
Gruntfile.js
node_modules/
client/
- grunt/
- images/
- js/
- sass/
Note: The node_modules
folder should not be committed to version control
Two commands run the tasks to compile your source files:
# watches your source files for changes to trigger compile
grunt watch
# compile with minification or production-specific settings
grunt build
Tasks are split up into module specific config structures. There are tons of other available grunt modules, this just gives us the basics.
client/grunt/
- compass.json
- concat.json
- cssmin.json
- imagemin.json
- jshint.json
- postcss.js
- scsslint.json
- uglify.json
Adding tasks is easy. load-grunt-config
automatically discovers installed modules and their config files.
# install a new grunt module and add it to package.json
npm install --save-dev grunt-contrib-htmlmin
# provide a config file for the module
vim client/grunt/htmlmin.json
# run the 'htmlmin' task
grunt htmlmin
# optionally add 'htmlmin' task to a parent script like watch
vim client/grunt/aliases.json
Some tasks need to be chained to be effective. For example, javascript files should be linted, concatenated and then minified.
{
"scripts": [
"jshint",
"concat",
"uglify"
],
"styles": [
"scsslint",
"compass",
"postcss",
"cssmin",
"imagemin"
],
"build": [
"scripts",
"styles"
]
}
Grunt requires some tedious gluing of things by hand, which is one reason people prefer an approach like the one taken by gulp
{{ title }}
component.js
var template = require('./template.html'),
compiled = Handlebars.compile(template),
context = { title: 'Webpack Wins' },
html = compiled(context);
document.body.appendChild(html);
Webpack crawls the tree for both require
and src
, so in this example, requiring component.js will bundle the template, and the image defined in the template. You can specify a number of preprocessors (urlencoded images, cache busting filenames, js transpilation, source maps, etc) to run on each of these file types directly in the stream. Relative links will be converted to work in the static production folder.