var gulp = require( 'gulp' ), nib = require( 'nib' ), fs = require( 'fs' ), marked = require( 'marked' ), karma = require( 'karma' ), browserSync = require( 'browser-sync' ), $ = require( 'gulp-load-plugins' )(); var paths = { build: [ 'elements/**/*.styl', 'elements/**/*.html', 'elements/**/*.js' , 'gui.html' ], lint: [ 'gulpfile.js', 'elements/**/*.js' ], test: [ 'build/gui.js', 'tests/*.js' ], clean: [ 'build/*', '**/*.css' ], docs: [ 'README.md', 'docs/*' ], shim: [ 'elements/shim.js' ] }; gulp.task( 'default', [ 'docs', 'lint', 'shim', 'build' ] ); gulp.task( 'watch', [ 'default' ], function() { karma.server.start( { frameworks: [ 'jasmine' ], files: paths.test } ); gulp.watch( paths.docs, [ 'docs' ] ); gulp.watch( paths.lint, [ 'lint' ] ); gulp.watch( paths.build, [ 'build' ] ); gulp.watch( paths.shim, [ 'shim' ] ); } ); gulp.task( 'build', [ 'vulcanize' ], function() { return gulp.src( 'build/gui.html' ) .pipe( $.replace( /\\/g, '\\\\' ) ) .pipe( $.replace( /'/g, '\\\'' ) ) .pipe( $.replace( /^(.*)$/gm, '\'$1\',' ) ) .pipe( $.insert.wrap( 'document.write([', '].join("\\n"))' ) ) .pipe( $.rename( 'gui.js' ) ) .pipe( gulp.dest( 'build' ) ); } ); gulp.task( 'vulcanize', [ 'css' ], function() { return gulp.src( 'gui.html' ) .pipe( $.vulcanize( { dest: 'build', inline: true, strip: true } ) ) // clean up some vulcanize ... .pipe( $.replace( /\n\n/gm, '' ) ) .pipe( $.replace( //gm, '' ) ) .pipe( $.replace( /^