See a live demo.
craft.js helps to manage, assess, build and distribute from a common JavaScript source code base.
# get craft.js from github
git clone https://github.com/marcbaechinger/craft.js.git
# install dependencies
cd craft.js/ && npm install
# start application
node server.js
Change the app-config.json
to adjust the port
on which the appication should listen.
{
"server": {
"port": 3000
},
"path": {
"base": "",
"src": "resources/repository",
"dist": "resources/dist",
"jobs": "resources/jobs",
"views": "views",
"docroot": "public"
},
"context": {
"src": "repo",
"dist": "dist",
"jobs": "jobs",
"default": "repo"
}
}
Declare dependencies of a script with a processing instruction at the top of a JavaScript file:
//= require "../../model/collection, ../../model/model"
//= require "/common/array"
//= require "ui-helper"
Multiple dependencies can be declared in a single processing instruction or with multiple instructions. craft.js takes care to concatenate the script in the declared order and avoids including the same file twice. The .js post fix must be omitted when declaring dependencies with a processing instruction.
resources
directory (see installation instructions).expand
, mangle
, squeeze
, minimize
, beautify
and lint
options. The transformed JavaScript file is displayed accordingly.Expanding repositories and transforming the resulting source code can be done on the fly and delivered with content type text/javascript. Hence it's easy to create a single 'bootstrap.js' declare the required dependencies with the 'require' processing instructions and load the file on the fly while development or for testing.
curl http://marc.no.de/repo/src/applications/craftjs/bootstrap.js?mangle=true&squeeze=true&minimize=true
Query parameters