Package Exports
- buildr
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (buildr) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Welcome to Buildr
The (Java|Coffee)Script and (CSS|Less) (Builder|Bundler|Packer|Minifier|Merger|Checker)
Install
Install CoffeeScript
npm -g install coffeescript
Install dependencies for image compression
On OSX
ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)" brew install gifsicle libjpeg optipng pngcrush
On Apt Linux
sudo apt-get update && sudo apt-get install gifsicle libjpeg-progs optipng pngcrush
On Yum Linux
sudo yum -y install gifsicle libjpeg-progs optipng pngcrush
Windows
Hahahahaha
Configure
Before you use Buildr, you must specify some configuration for it. The available configuration is:
{
# Paths
srcPath: false # String
outPath: false # String or false
# Loaders
srcLoaderHeader: false # String or false
srcLoaderPath: false # String or false
# Bundling
bundleScripts: false # Array or false
bundleStyles: false # Array or false
bundleScriptPath: false # String or false
bundleStylePath: false # String or false
deleteBundledFiles: true # true or false
# Checking
checkScripts: true # Array or true or false
checkStyles: true # Array or true or false
jshintOptions: false # Object or false
csslintOptions: false # Object or false
# Compression
compressScripts: true # Array or true or false
compressStyles: true # Array or true or false
}
The above values are the default values for those options. The settings which are set to true
will autodect the files for you.
Checking
To pass your scripts through jshint, and your styles through csslint, you'd want the following configuration:
{
# Paths
srcPath: 'src' # String
# Checking
checkScripts: true # Array or true or false
checkStyles: true # Array or true or false
jshintOptions: false # Object or false
csslintOptions: false # Object or false
}
Compression
To copy your src
directory to an out
directory, then compile and compress all your styles and scripts in the out
directory, you'd want the following configuration:
{
# Paths
srcPath: 'src' # String
outPath: 'out' # String or false
# Compression
compressScripts: true # Array or true or false
compressStyles: true # Array or true or false
}
Bundling
To bundle all your style files into one file called out/bundled.css
and all your script files into one file called out/bundled.js
, you'd want the following configuration:
{
# Paths
srcPath: 'src' # String
outPath: 'out' # String or false
# Bundling
bundleScripts: [
'script1.js'
'script2.coffee'
] # Array or false
bundleStyles: [
'style1.css'
'style2.less'
] # Array or false
bundleScriptPath: 'out/bundled.js' # String or false
bundleStylePath: 'out/bundled.css' # String or false
deleteBundledFiles: true # true or false
}
Loaders
To generate a source loader file called src/loader.js
which will load in all your source styles and scripts into the page, you can use the following:
{
# Paths
srcPath: 'src' # String
# Loaders
srcLoaderHeader: '''
# Prepare
myprojectEl = document.getElementById('myproject-include')
myprojectBaseUrl = myprojectEl.src.replace(/\\?.*$/,'').replace(/loader\\.js$/, '').replace(/\\/+$/, '')+'/'
# Load in with Buildr
myprojectBuildr = new window.Buildr {
baseUrl: myprojectBaseUrl
beforeEl: myprojectEl
serverCompilation: window.serverCompilation or false
scripts: scripts
styles: styles
}
myprojectBuildr.load()
''' # note, all \ in this are escaped due to it being in a string
srcLoaderPath: 'src/myproject.loader.js' # String or false
# Bundling
bundleScripts: [
'script1.js'
'script2.coffee'
] # Array or false
bundleStyles: [
'style1.css'
'style2.less'
] # Array or false
}
Then include into your page with the following html:
<script id="myproject-include" src="../../loader.js"></script>
Combining
You can feel free to combine any of the configurations above to get something which checks, compiles, compresses, bundles, and generates loaders too. Though compression and bundling is dependent on having an outPath
which is different from your srcPath
.
Run
As a Command Line Tool
Note: this option is currently disabled due to this bug
Install Buildr Globally
npm -g install buildr
Stick your configuration in
app/buildr.cson
Within your app root, run
buildr
As a Module
Install Buildr Locally
npm install buildr
Code
buildr = require 'buildr' config = {} # your configuration myBuildr = buildr.createInstance(config) myBuildr.process (err) -> throw err if err console.log 'Building completed'
License
Licensed under the MIT License Copyright 2011 Benjamin Arthur Lupton
History
Changelog
v0.6 July 21, 2011
- Added javascript compression
- Added jshint and csslint checks
- Added image compression
- Added css compression
v0.5 July 9, 2011
- Added srcLoader compilation
v0.4 July 1, 2011
- Extremely Simplified
- Only supports bundling of js|coffee and css|less files currently
v0.3 May 31, 2011
- Exploration into better architectures
v0.2 April 2, 2011
- Initial Release
v0.1 March 23, 2011
- Initial Commit
Todo
- Needs auto file finding for bundling
- Needs no-config version
- Needs unit tests