Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // views task: bundle all html templates into a templatecache (a big blob of html in a js file),
- // rename it app.templates.js and move it to ./src/js/config/
- gulp.task('views', function () {
- return (
- gulp
- // take all the html templates
- .src(viewFiles)
- // pipe them into a templatecache file
- .pipe(
- templateCache({
- standalone: true,
- })
- )
- // if there are errors, print them
- .on('error', interceptErrors)
- // rename the file app.templates.js
- .pipe(rename('app.templates.js'))
- // move it to ./src/js/config/
- .pipe(gulp.dest('./src/js/config/'))
- );
- });
- // browserify task: run views to get the HTML into ./src/js/config, then bundle up all the
- // JS, JS dependencies, and HTML into a big file of ES5 Javascript called main.js in the ./build/ folder
- gulp.task('browserify', ['views'], function () {
- return (
- // bundle up all the JS through the root file app.js
- browserify('./src/js/app.js')
- // transpile to es5
- .transform(babelify, {presets: ['es2015']})
- // inject dependencies
- .transform(ngAnnotate)
- // bundle the js
- .bundle()
- // error => use interceptErrors passthrough
- .on('error', interceptErrors)
- // output to main.js
- .pipe(source('main.js'))
- // move main.js to ./build
- .pipe(gulp.dest('./build/'))
- );
- });
Advertisement
Add Comment
Please, Sign In to add comment