This tip is based off of v0.6.1.
The source code for enchant.js exists within the enchant.js, but this file is created from
dev/src/*.js (github). The dev/src folder contains files which separate out the different parts of enchant.js by class. For instance the code which makes up the Sprite class is located in
dev/src/sprite.js. To search for code which makes up a specific class, this is the best way to find it.
dev/src/ must undergo a syntax check, be combined, and then optimized in order to create
enchant.min.js. This is called the build process. If files in
dev/src/ are edited, they must undergo the build process again in order to be usable in working script.
The following tools are required for the build process:
- npm (node package manager)
Ruby and rake are included by default on most installations of OSX and Linux. Node.js and npm can be downloaded from http://node.io. After installing Node.js and npm, navigate to the enchant.js directory in command line, and type
npm install to install the required package.
grunt command is what begins the build process (More info on grunt). Several different options are available when building, but by default, grunt runs
lint:core concat min qunit exec:lang. These commands do the following:
- lint: js – Checks code syntax
- concat: – Creates
- min: – Creates
- qunit: – Carries out unit testing on
dev/enchant.jswith qunit, via phantomjs
- exec:lang: – Creates
ja/enchant.js, etc. based off of language of comments in the code from
Specific build tasks can be performed, such as
grunt lint, etc., but keep in mind that if any files within
dev/src are changed,
concat min will be run automatically due to
grunt watch. (
grunt watch monitors files in a directory for changes.)
This post is also available in: Japanese