Git Product home page Git Product logo

mass's Introduction

Merge and Simplify Scripts (MASS)

Inspired by SASS, the goal is to build an automated tool system for managing javascript files in a project.

Goals

  • easy method to combine multiple files into single asset request
  • automated minification/optimization
  • extending javascript to allow import other scripts

##Requirements

  • Mac OS X (currently using fsevents to track file changes. will later add support for Linux and Windows)

Python Packages Used

##Installation

To install MASS, clone the repo and install using setup.py:

python setup.py install

MASS comes with the necessary python packages via virutalenv by default. Before starting MASS, navigate to the repository and start the virutal environment.

If the virtual environment is not started, python packages must be installed to the local python environment using pip.

cd path/to/MASS
source env/bin/activate

Source Files

Source files use the extension '.xjs', which tentatively signifies extended javascript. These files are used to define javascript files which will be included in a "compiled" version that is output by MASS.

Including Files

Inside 'extended' javascript files, you can import other scripts. All javascript files listed in the source file will be combined, minified and output to a javascript file with the same name as the original xjs file. Paths to imported javascript files should be relative to the directory of the xjs file they are imported into.

The example below specifies two javascript files and will be output to the file foo.min.js:

# foo.xjs
#!import 'foo.js'
#!@import 'plugins/jquery.jnotify.js'

Require commands can be used to ensure that a file has been already been imported, and will import the script if they have not.

# foo.xjs
#!import 'foo.js'
#!import 'bar.js'

# foo.js
#!require 'bar.js' 

In the above example, bar.js will not be re-imported since foo.xjs has already imported it.

MASS also supports 'inline' javascript

# bar.js
#!import 'foo.js'

# now some javascript 
$(document).ready(function(){
    // jquery is ready
});

# another import!
#!import 'plugins/jquery.jnotify.js'

CLI Arguments

###Defining Destination Directory

By default, MASS saves the compiled js files in the same directory as the source files. The -d argument can be used to specify a different output directory.

mass watch -d path/to/output

###Defining Source Directory

If a source directory is not specified, MASS uses the current directory by default. The -s argument can be used to specify the directory for MASS to discover files.

mass watch -s path/to/source -d path/to/output

mass's People

Contributors

apcomplete avatar jackboberg avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.