xonecas.io
142
St

startsInvasion / files

startsInvasion / libs / node_modules / bean / support / smoosh / README.md

4.6 KB
1SMOOOOSH.
2=========
3How would you smoosh a lion and a tiger? A tialiganer, right?
4
5![smoosh](http://f.cl.ly/items/3o0y3m3o2Z3l1e0i1V2V/Screen%20shot%202011-03-05%20at%2012.13.54%20AM.png)
6
7SMOOSH is a tool for packaging your javascript projects... it will run [JSHint](http://jshint.com) against your files, then build and minify your files if you'd like with [UglifyJS](https://github.com/mishoo/UglifyJS)
8
9to install smoosh do something like this...
10
11    npm install smoosh
12
13CONFIG
14======
15Currently, smoosh requires a config.json file to work. Your config file should look something like this (check the examples folder for a working example):
16
17    {
18      "VERSION": "0.1", // optional
19      "DIST_DIR": "dist", // optional
20      "JSHINT_OPTS": { ... }
21      "JAVASCRIPT": {
22        "base": [ ... ],
23        "secondary": [ ... ]
24      }
25    }
26
27Your config options include:
28
29  + VERSION: an optional version number which will be appended to your built files
30  + JAVASCRIPT:
31  + key: the name of your compiled file (ie: 'mootools-core', 'base-bundle', etc.)
32  + value: an array of file paths to be bundled (ie. ['./src/drag.js', './src/drop.js'])
33  + DIST_DIR: the directory to output your files to (if no directory is specified, 'dist' will be used)
34  + JSHINT_OPTS: the options to use if running jshint
35
36USING SMOOSH WITH TERMINAL
37==========================
38
39once installed with npm, smoosh can be accessed easily from the command line! Just create your config file (shown above), then run commands. Here's a list of some of them:
40
41
42    //any of these commands will execute all smoosh tasks with config.json
43    smoosh ./config.json
44    smoosh make ./config.json
45    smoosh -m ./config.json
46
47    //executing either of these commands will destroy the dist folder
48    smoosh clean ./config.json
49    smoosh -d ./config.json
50
51    //these will generate ugliyjs minified versions of your packaged source
52    smoosh compressed ./config.json
53    smoosh -c ./config.json
54
55    //these will generate full, uncompressed version of your packaged source
56    smoosh uncompressed
57    smoosh -f ./config.json
58
59    //executing either of these commands will build both compressed and uncompressed versions of your source
60    smoosh build ./config.json
61    smoosh -b ./config.json
62
63    //these will run jshint against your uncompressed source
64    smoosh run ./config.json
65    smoosh -r ./config.json
66
67    //the -a flag will run analyze.. you must include a build type for analyze to work
68    smoosh -ca ./config
69    smoosh -ba ./config
70    smoosh -fa ./config
71
72    //as you might have guessed, you can specify multiple flags at the same time
73    smoosh -dba ./config //<-- this will clean the dist folder, build new files, and then analyze them
74
75
76USING SMOOSH WITH THE CODEZ
77===========================
78
79once installed, smoosh is pretty easy to use...
80
81    var smoosh = require('smoosh');
82
83Once required there are several methods available to you:
84
85CONFIG
86------
87As stated above, smoosh requires that you pass it the path to your configuration json file. To do that, you would do:
88
89    smoosh.config('./config.json')
90
91CLEAN
92-----
93The clean method will remove your distribution directory. **Warning** This will empty your entire DIST directory. So this may be unwanted behavior if your DIST directory is "./". It is preferred that this is only used when you have a dedicated dist folder. Eg: "./src/build" or "./dist"
94
95    smoosh.clean();
96
97RUN
98---
99Run takes one argument; a string which specifies what to run. Currently run only works with jslint, therefore you can do either:
100
101    smoosh.run('jslint');
102
103    //or
104
105    smoosh.run();
106
107In the future we may add more useful things here.
108
109BUILD
110-----
111Build is used to build your sources together. You can build uncompressed or compressed files or both! You can use it like this:
112
113    smoosh.build('uncompressed');
114
115    //or
116
117    smoosh.build('compressed');
118
119    //or
120
121    smoosh.build() // <-- this will build both compressed and uncompressed
122
123
124ANALYZE
125-------
126Analyzed is useful when you're curious if you're making your files larger or smaller. It will return relevant file size for uncompressed, compressed, or gzipped files.
127
128    smoosh.analyze('uncompressed');
129
130    //or
131
132    smoosh.analyze('compressed');
133
134    //or
135
136    smoosh.analyze('gzipped'); //it gzips the compressed files only
137
138    //or
139
140    smoosh.analyze(); //which will do analyze all types
141
142MAKE
143----
144Make can currently be used as a shortcut to run all smoosh methods... It requires one argument, the path to the config file.json.
145
146    smoosh.make('./config.json');
147
148    //is the same as
149    smoosh.config('./config.json').run().build().analyze();
150
151CHAINING
152--------
153Note: that smoosh supports chaining, if you're into that sorta thing.