| /* |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| */ |
| 'use strict'; |
| |
| var gulp = require('gulp'), |
| runSequence = require('run-sequence'); |
| |
| var $ = require('gulp-load-plugins')({ |
| pattern: ['gulp-*', 'main-bower-files', 'uglify-save-license', 'del'] |
| }); |
| |
| gulp.task('styles', ['wiredep', 'injector:css:preprocessor'], function () { |
| return gulp.src(['src/app/index.scss', 'src/app/vendor.scss']) |
| .pipe($.sass({style: 'expanded'})) |
| .on('error', function handleError(err) { |
| console.error(err.toString()); |
| this.emit('end'); |
| }) |
| .pipe($.autoprefixer('last 1 version')) |
| .pipe(gulp.dest('.tmp/app/')); |
| }); |
| |
| gulp.task('injector:css:preprocessor', function () { |
| return gulp.src('src/app/index.scss') |
| .pipe($.inject(gulp.src([ |
| 'src/{app,components}/**/*.scss', |
| '!src/app/index.scss', |
| '!src/app/vendor.scss' |
| ], {read: false}), { |
| transform: function(filePath) { |
| filePath = filePath.replace('src/app/', ''); |
| filePath = filePath.replace('src/components/', '../components/'); |
| return '@import \'' + filePath + '\';'; |
| }, |
| starttag: '// injector', |
| endtag: '// endinjector', |
| addRootSlash: false |
| })) |
| .pipe(gulp.dest('src/app/')); |
| }); |
| |
| gulp.task('injector:css', ['styles'], function () { |
| return gulp.src('src/index.html') |
| .pipe($.inject(gulp.src([ |
| '.tmp/{app,components}/**/*.css', |
| '!.tmp/app/vendor.css' |
| ], {read: false}), { |
| ignorePath: '.tmp', |
| addRootSlash: false |
| })) |
| .pipe(gulp.dest('src/')); |
| }); |
| |
| gulp.task('jshint', function () { |
| return gulp.src('src/{app,components}/**/*.js') |
| .pipe($.jshint()) |
| .pipe($.jshint.reporter('jshint-stylish')); |
| }); |
| |
| gulp.task('injector:js', ['jshint', 'injector:css'], function () { |
| return gulp.src('src/index.html') |
| .pipe($.inject(gulp.src([ |
| 'src/{app,components,vendor}/**/*.js', |
| '!src/{app,components,vendor}/**/*.spec.js', |
| '!src/{app,components,vendor}/**/*.mock.js' |
| ], {read: false}), { |
| ignorePath: 'src', |
| addRootSlash: false |
| })) |
| .pipe(gulp.dest('src/')); |
| }); |
| |
| gulp.task('partials', function () { |
| return gulp.src('src/{app,components}/**/*.html') |
| .pipe($.htmlmin({ |
| empty: true, |
| spare: true, |
| quotes: true |
| })) |
| .pipe($.angularTemplatecache('templateCacheHtml.js', { |
| module: 'odeConsole' |
| })) |
| .pipe(gulp.dest('.tmp/inject/')); |
| }); |
| |
| gulp.task('html', ['wiredep', 'injector:css', 'injector:js', 'partials'], function () { |
| var htmlFilter = $.filter('*.html',{restore: true}); |
| var jsFilter = $.filter('**/*.js',{restore: true}); |
| var cssFilter = $.filter('**/*.css',{restore: true}); |
| |
| return gulp.src('src/*.html') |
| .pipe($.inject(gulp.src('.tmp/inject/templateCacheHtml.js', {read: false}), { |
| starttag: '<!-- inject:partials -->', |
| ignorePath: '.tmp', |
| addRootSlash: false |
| })) |
| .pipe($.useref()) |
| //.pipe($.rev()) |
| .pipe(jsFilter) |
| .pipe($.ngAnnotate()) |
| .pipe($.uglify({preserveComments: $.uglifySaveLicense})) |
| .pipe(jsFilter.restore) |
| .pipe(cssFilter) |
| .pipe($.replace('bower_components/bootstrap-sass-official/assets/fonts/bootstrap','styles/fonts')) |
| .pipe($.csso()) |
| .pipe(cssFilter.restore) |
| .pipe($.useref()) |
| .pipe($.revReplace()) |
| .pipe(htmlFilter) |
| .pipe($.htmlmin({ |
| empty: true, |
| spare: true, |
| quotes: true |
| })) |
| .pipe(htmlFilter.restore) |
| .pipe(gulp.dest('dist/')) |
| .pipe($.size({ title: 'dist/', showFiles: true })); |
| }); |
| |
| gulp.task('images', function () { |
| return gulp.src('src/assets/images/**/*') |
| .pipe($.cache($.imagemin({ |
| optimizationLevel: 3, |
| progressive: true, |
| interlaced: true |
| }))) |
| .pipe(gulp.dest('dist/assets/images/')); |
| }); |
| |
| gulp.task('fonts', function () { |
| return gulp.src($.mainBowerFiles()) |
| .pipe($.filter('**/*.{eot,svg,ttf,woff,woff2}')) |
| .pipe($.flatten()) |
| .pipe(gulp.dest('dist/styles/fonts/')); |
| }); |
| |
| gulp.task('misc', function () { |
| return gulp.src('src/**/*.ico') |
| .pipe(gulp.dest('dist/')); |
| }); |
| |
| gulp.task('clean', function () { |
| return $.del.sync(['dist/', '.tmp/']); |
| }); |
| |
| gulp.task('build', function(done){ |
| runSequence('clean', 'html', 'images', 'fonts', 'misc',done); |
| }); |
| |