Syrup
A collection of shared UI utilities and libraries leveraged by AI2 when developing interfaces.
Specifically, syrup provides:
- A series of gulp tasks for building a single-page client-side application.
- A collection of less styles. To see them in action, visit the demo.
Requirements
Installation
Install via npm:
npm install syrup
Gulp
Syrup includes a series of gulp tasks useful for building a single-page client-side application.
The gulp tasks provided by syrup can be initialized like so in your gulpfile.js
:
var gulp = require('gulp');
var syrup = require('syrup');
syrup.gulp.init(gulp);
A build can then be triggered from the terminal:
gulp build
Watch your project for changes dynamically and start a static HTTP server for previewing the result:
gulp watch-and-serve
Read about all of the available gulp tasks, the default project structure or the full API offered by the syrup.gulp.init()
.
LESS
To include the all of the less styles provide by syrup, simply add the following line to your less stylesheet:
@import '../../node_modules/syrup/less/syrup.less';
Gulp Tasks
Syrup provides the following tasks:
- Removes all build artifacts
less
- Compiles and minifies LESS files to CSS files.
jslint
- Lints JS files using jshint.
js
- Bundles, minifies and obfuscates
js
files using browserify into a single, bundled script. Uses babel to provide support for ECMA6 features and ReactJS. assets
- Copies all assets into the build directory.
html
- Copies the
index.html
file into the build directory after running the js
, assets
, and less
tasks. build
- Builds the project by running the
assets
, jslint
, js
, less
, and html
tasks. watch
- Watches the project for changes and rebuilds the affected components as they occur.
serve
- Runs an express HTTP serving serving the application.
watch-and-serve
- Runs the
watch
and serve
tasks.
Default Project Structure
The following project structure is expected by default, but can be changed via the paths
parameter
of syrup.gulp.init()
:
{
html: 'app/index.html',
allLess: 'app/**/*.less',
less: 'app/main.less',
jsLint: 'app/**/*.js',
js: 'app/app.js',
assets: 'app/assets/**/*',
build: 'build'
}
Gulp API
syrup.gulp.init(gulp, options, configParameters, paths)