Created
May 21, 2016 21:27
-
-
Save jhades/16e30eeaa3a397562b695930bfa58c55 to your computer and use it in GitHub Desktop.
A complete toolchain for AngularJs - Gulp, Browserify, Sass
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gulp.task('build-css', ['clean'], function() { | |
return gulp.src('./styles/*') | |
.pipe(sourcemaps.init()) | |
.pipe(sass()) | |
.pipe(cachebust.resources()) | |
.pipe(sourcemaps.write('./maps')) | |
.pipe(gulp.dest('./dist')); | |
}); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gulp.task('build-js', ['clean'], function() { | |
var b = browserify({ | |
entries: './js/app.js', | |
debug: true, | |
paths: ['./js/controllers', './js/services', './js/directives'], | |
transform: [ngAnnotate] | |
}); | |
return b.bundle() | |
.pipe(source('bundle.js')) | |
.pipe(buffer()) | |
.pipe(cachebust.resources()) | |
.pipe(sourcemaps.init({loadMaps: true})) | |
.pipe(uglify()) | |
.on('error', gutil.log) | |
.pipe(sourcemaps.write('./')) | |
.pipe(gulp.dest('./dist/js/')); | |
}); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gulp.task('sprite', function () { | |
var spriteData = gulp.src('./images/*.png') | |
.pipe(spritesmith({ | |
imgName: 'todo-sprite.png', | |
cssName: '_todo-sprite.scss', | |
algorithm: 'top-down', | |
padding: 5 | |
})); | |
spriteData.css.pipe(gulp.dest('./dist')); | |
spriteData.img.pipe(gulp.dest('./dist')) | |
}); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gulp.task('build', [ 'clean', 'bower','build-css','build-template-cache', 'jshint', 'build-js'], function() { | |
return gulp.src('index.html') | |
.pipe(cachebust.references()) | |
.pipe(gulp.dest('dist')); | |
}); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gulp.task('test', ['build-js'], function() { | |
var testFiles = [ | |
'./test/unit/*.js' | |
]; | |
return gulp.src(testFiles) | |
.pipe(karma({ | |
configFile: 'karma.conf.js', | |
action: 'run' | |
})) | |
.on('error', function(err) { | |
console.log('karma tests failed: ' + err); | |
throw err; | |
}); | |
}); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gulp.task('jshint', function() { | |
gulp.src('/js/*.js') | |
.pipe(jshint()) | |
.pipe(jshint.reporter('default')); | |
}); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gulp.task('webserver', ['watch','build'], function() { | |
gulp.src('.') | |
.pipe(webserver({ | |
livereload: false, | |
directoryListing: true, | |
open: "<a href="http://localhost:8000/dist/index.html">http://localhost:8000/dist/index.html</a>" | |
})); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment