
ReadyMade makes it easier for webdevelopers and designers to work with assets that requires compilation : CoffeeScript, Less css, Sass, Stylus, Uglify, markdown ... and obviously all of your static files that don't require compilation (images, css, js, etc.).
It can work as a standalone server or integrate with ExpressJS.
Serve your file for development
ReadyMade offers you one single solution to compile your assets on-the-fly when you are developing.
Contrary to the -watch option many compilers offer, ReadyMade compiles your files when you refresh your browser. A detailed error page will be served if your file compilation fails. To get the server running and serve your assets on localhost:10000, just cd to your media directory root and run :
readymade serve
For instance, if you have a CoffeeScript source file in
./js/myfile.coffee
and you request for
http://localhost:10000/js/myfile.js
Your CoffeeScript file will get compiled and served.
Compiled files are cached (by default in a .readymade directory). The compilation will occur only if it is required.
Build your files for production
You can also build most of assets using one single command.
readymade build <file1> <file2> ...
You may also write all your targets' path (one per line) in a target file and build all of them at once via
readymade build -t <your-target-file>
By default, files are compiled in place. You can define a specific build directory by
readymade build -t <your-target-file> -d <your-build-dir>
Formats handled by default
Type of asset | Target file | Source file | Compiler installation |
---|---|---|---|
CoffeeScript | .js | .coffee | npm install coffee-script |
Coco | .js | .coco | npm install coco |
LiveScript | .js | .ls | npm install LiveScript |
Less | .css | .less | npm install less |
Sass | .css | .scss or .sass | gem install sass |
Stylus | .css | .styl | npm install stylus |
Uglify JS | .min.js | .js | npm install uglifyjs |
Markdown | .html | .md | npm install markitup |
Markdown and Jade | .html | .md and .jade | npm install markitup |
Mustache templates (via Hogan) |
templates.js | a "mustaches" directory containing all your templates. |
npm install markitup |
How to extend
ReadyMade works on Makefile. You can define extend its default configuration by writing your own building rule.
For instance, I could define the way to define a rule to copy files to .copy file by creating and editing readymade.Makefile.
##############################
# Copy file
# (.*) -> (.*.copy)
${build_path}/%.copy: %
mkdir -p `dirname $@`
cp $^ $@
This rule will be active if you run either readymade serve or readymade build with the -f option :
readymade serve -f readymade.Makefile
How to install
ReadyMade requires NodeJS and Make to be installed on your computer. Make comes by default on most Linux Distribution and with XCode on MacOS (dunno about Windows).
Once it is installed, you can install readymade via
npm install readymade -g
(You might need to sudo your way through this command.)
You will also need to install separately all of the compilers you need.
Integrate with express
Readymade is up and running just by adding one line in your app.configure:
app.configure(function(){
// ...
app.use(require('readymade').middleware({root: "public"}));
// ...
});
Readymade will then server the content within ./public content on /public. In order to extend readymade with your own building rules, just pass the path to your makefile with the makefile option.
app.configure(function(){
// ...
var readymadeOptions = {
root: "public",
makefile:"./readymade.Makefile"
};
app.use(require('readymade').middleware(readymadeOptions));
// ...
});
More help
Get more information about command-line options via :
readymade help (action)