marcbaechinger / craft.js

JavaScript crafting tool
6 stars 1 forks source link

craft.js - javascript build tool

See a live demo.

craft.js helps to manage, assess, build and distribute from a common JavaScript source code base.

Installation

 # 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

Configuration

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"
    }
}

declaring dependencies in a script

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.

Usage

Browse repository

Create a distribution

Delivering JavaScripts on the fly

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