g33k-packer

2.0.6 • Public • Published

G33K PACKER

How To Use

In our project firectory, the best is to create a folder called 'packer' at the project root. In the folder, create a file 'index.js' and copy the sample code to it.

By default, the sample code will move his working directory to the project root process.chdir(path.normalize(__dirname+'/../')) ;

workingDir variable will be the root of your project.

Options

  • packages : could be an object like in sample code or a json file

Run

Run it by being placed in your root directory and call

node packer/

Sample Code

// Test if packer is installed
try {
    console.log(require.resolve("g33k-packer"));
} catch(e) {
    console.error("g33k-packer package is not installed!\nPlease run `npm update` in the directory.");
    process.exit(e.code);
}

// Load libs
var path = require('path'),
    fs = require('fs'),
    Packer = require('g33k-packer'); 

// Change working path
process.chdir(path.normalize(__dirname+'/../')) ;

// Get working dir
var workingDir = process.cwd();

// Create Packer Instance
var packer = new Packer(workingDir, {

    // Debug
    debug: false,

    // Paths to scan in the working dir
    "scanPath": ["/app", "/public/assets"],

    // Only work on thoses extensions
    "scanExt": /\.(html|js|css|tpl|less)$/i,

    // Ignore files with regexp filters applied to full path
    "scanIgnore": /(tmp\/|server-.*\.js)/,

    // Packed path
    "packedPath": "/public/packed",

    // Minify options
    "minifyJS": true,
    "minifyCSS": true,
    "minifyHTML": true,

    // Watch for file updates every (in ms)
    "watch": 500,

    // Copy minfied unit files to packedPath
    "copy": false,

    // Enable livereload support 
    "livereload": true,
    
    // Declare packages
    "packages": {

        // Main CSS file (will be placed to packedPath/app.min.css)
        "/app.min.css": [
            "/assets/vendors/bootstrap/css/bootstrap.css",
            "/assets/vendors/markdown/highlight.monokai.css",
            "/assets/css/main.less",
            "/views/auth/style.less",
            "/views/discover/welcome.less",
        ],

        // Main JS file (will be placed to packedPath/app.min.js)
        "/app.min.js": [
            "/assets/vendors/jquery/jquery-1.10.2.min.js",
            "/assets/vendors/bootstrap/js/bootstrap.js",
            "/assets/vendors/async.js",
            "/assets/vendors/underscore/underscore-1.5.2.min.js",
            "/assets/vendors/backbone/backbone-1.0.min.js",
            "/assets/vendors/backbone/backbone.view.extend.js",
            "/assets/vendors/mustache.min.js",
            "/assets/vendors/markdown/markdown.js",
            "/assets/vendors/markdown/highlight.min.js",
            "/assets/vendors/moment+langs.js",
            "/assets/vendors/jquery.activity-indicator-1.0.0.min.js",
            "/assets/js/app.js"
        ]

    }

}); 

Readme

Keywords

none

Package Sidebar

Install

npm i g33k-packer

Weekly Downloads

7

Version

2.0.6

License

none

Last publish

Collaborators

  • g33klabs