From de84aaa77f393261c1745c7ef34bd843323f854a Mon Sep 17 00:00:00 2001 From: Vladimir Lugovsky Date: Mon, 14 Dec 2015 21:22:38 +0300 Subject: [PATCH] feat(build): adjust build to latest Swiip version --- gulp/build.js | 2 +- gulp/conf.js | 2 +- gulp/inject.js | 6 ++++ gulp/scripts.js | 15 ++++++++-- gulp/server.js | 12 ++++++-- gulp/styles.js | 16 ++++++++--- gulp/watch.js | 10 +++---- package.json | 74 ++++++++++++++++++++++++++++--------------------- 8 files changed, 89 insertions(+), 48 deletions(-) diff --git a/gulp/build.js b/gulp/build.js index cf4c833..87cc06a 100644 --- a/gulp/build.js +++ b/gulp/build.js @@ -19,7 +19,7 @@ gulp.task('partials', function () { quotes: true })) .pipe($.angularTemplatecache('templateCacheHtml.js', { - module: 'angularBestPractices', + module: '123', root: 'app' })) .pipe(gulp.dest(conf.paths.tmp + '/partials/')); diff --git a/gulp/conf.js b/gulp/conf.js index 061528a..7d4a0c9 100644 --- a/gulp/conf.js +++ b/gulp/conf.js @@ -24,7 +24,7 @@ exports.paths = { * to inject css preprocessor deps and js files in karma */ exports.wiredep = { - exclude: [/jquery/, /\/bootstrap\.js$/, /\/bootstrap-sass\/.*\.js/, /\/bootstrap\.css/], + exclude: [/\/bootstrap\.js$/, /\/bootstrap-sass\/.*\.js/, /\/bootstrap\.css/], directory: 'bower_components' }; diff --git a/gulp/inject.js b/gulp/inject.js index c296052..2a5804b 100644 --- a/gulp/inject.js +++ b/gulp/inject.js @@ -9,6 +9,12 @@ var $ = require('gulp-load-plugins')(); var wiredep = require('wiredep').stream; var _ = require('lodash'); +var browserSync = require('browser-sync'); + +gulp.task('inject-reload', ['inject'], function() { + browserSync.reload(); +}); + gulp.task('inject', ['scripts', 'styles'], function () { var injectStyles = gulp.src([ path.join(conf.paths.tmp, '/serve/app/**/*.css'), diff --git a/gulp/scripts.js b/gulp/scripts.js index 57b5267..585e4fc 100644 --- a/gulp/scripts.js +++ b/gulp/scripts.js @@ -8,10 +8,19 @@ var browserSync = require('browser-sync'); var $ = require('gulp-load-plugins')(); -gulp.task('scripts', function () { + +gulp.task('scripts-reload', function() { + return buildScripts() + .pipe(browserSync.stream()); +}); + +gulp.task('scripts', function() { + return buildScripts(); +}); + +function buildScripts() { return gulp.src(path.join(conf.paths.src, '/app/**/*.js')) .pipe($.eslint()) .pipe($.eslint.format()) - .pipe(browserSync.reload({ stream: true })) .pipe($.size()) -}); +}; diff --git a/gulp/server.js b/gulp/server.js index 88b8b82..500b0c0 100644 --- a/gulp/server.js +++ b/gulp/server.js @@ -31,9 +31,9 @@ function browserSyncInit(baseDir, browser) { * You just have to configure a context which will we redirected and the target url. * Example: $http.get('/users') requests will be automatically proxified. * - * For more details and option, https://github.com/chimurai/http-proxy-middleware/blob/v0.0.5/README.md + * For more details and option, https://github.com/chimurai/http-proxy-middleware/blob/v0.9.0/README.md */ - // server.middleware = proxyMiddleware('/users', {target: 'http://jsonplaceholder.typicode.com', proxyHost: 'jsonplaceholder.typicode.com'}); + // server.middleware = proxyMiddleware('/users', {target: 'http://jsonplaceholder.typicode.com', changeOrigin: true}); browserSync.instance = browserSync.init({ startPath: '/', @@ -53,3 +53,11 @@ gulp.task('serve', ['watch'], function () { gulp.task('serve:dist', ['build'], function () { browserSyncInit(conf.paths.dist); }); + +gulp.task('serve:e2e', ['inject'], function () { + browserSyncInit([conf.paths.tmp + '/serve', conf.paths.src], []); +}); + +gulp.task('serve:e2e-dist', ['build'], function () { + browserSyncInit(conf.paths.dist, []); +}); diff --git a/gulp/styles.js b/gulp/styles.js index bf17202..9eada3f 100644 --- a/gulp/styles.js +++ b/gulp/styles.js @@ -11,7 +11,16 @@ var $ = require('gulp-load-plugins')(); var wiredep = require('wiredep').stream; var _ = require('lodash'); -gulp.task('styles', function () { +gulp.task('styles-reload', ['styles'], function() { + return buildStyles() + .pipe(browserSync.stream()); +}); + +gulp.task('styles', function() { + return buildStyles(); +}); + +var buildStyles = function() { var sassOptions = { style: 'expanded' }; @@ -41,6 +50,5 @@ gulp.task('styles', function () { .pipe($.sass(sassOptions)).on('error', conf.errorHandler('Sass')) .pipe($.autoprefixer()).on('error', conf.errorHandler('Autoprefixer')) .pipe($.sourcemaps.write()) - .pipe(gulp.dest(path.join(conf.paths.tmp, '/serve/app/'))) - .pipe(browserSync.reload({ stream: true })); -}); + .pipe(gulp.dest(path.join(conf.paths.tmp, '/serve/app/'))); +}; diff --git a/gulp/watch.js b/gulp/watch.js index 16eb324..f748ccb 100644 --- a/gulp/watch.js +++ b/gulp/watch.js @@ -12,24 +12,24 @@ function isOnlyChange(event) { gulp.task('watch', ['inject'], function () { - gulp.watch([path.join(conf.paths.src, '/*.html'), 'bower.json'], ['inject']); + gulp.watch([path.join(conf.paths.src, '/*.html'), 'bower.json'], ['inject-reload']); gulp.watch([ path.join(conf.paths.src, '/app/**/*.css'), path.join(conf.paths.src, '/app/**/*.scss') ], function(event) { if(isOnlyChange(event)) { - gulp.start('styles'); + gulp.start('styles-reload'); } else { - gulp.start('inject'); + gulp.start('inject-reload'); } }); gulp.watch(path.join(conf.paths.src, '/app/**/*.js'), function(event) { if(isOnlyChange(event)) { - gulp.start('scripts'); + gulp.start('scripts-reload'); } else { - gulp.start('inject'); + gulp.start('inject-reload'); } }); diff --git a/package.json b/package.json index a05aef4..e2fef1c 100644 --- a/package.json +++ b/package.json @@ -2,38 +2,48 @@ "name": "blur_admin", "version": "0.0.1", "devDependencies": { - "bower": "^1.5.2", - "browser-sync": "^2.10.0", - "browser-sync-spa": "^1.0.3", - "event-stream": "^3.3.1", - "gulp": "^3.9.0", - "gulp-angular-filesort": "^1.1.1", - "gulp-angular-templatecache": "^1.7.0", - "gulp-autoprefixer": "^2.3.1", - "gulp-changed": "^1.3.0", - "gulp-concat": "^2.6.0", - "gulp-eslint": "^1.1.1", - "gulp-filter": "^3.0.1", - "gulp-flatten": "^0.2.0", - "gulp-imagemin": "^2.3.0", - "gulp-inject": "^3.0.0", - "gulp-load-plugins": "^1.1.0", - "gulp-minify-css": "^1.2.1", - "gulp-minify-html": "^1.0.4", - "gulp-prompt": "^0.1.2", - "gulp-rename": "^1.2.2", - "gulp-sass": "^2.0.4", - "gulp-size": "^2.0.0", - "gulp-sourcemaps": "^1.6.0", - "gulp-strip-debug": "^1.0.2", - "gulp-uglify": "^1.4.0", - "gulp-useref": "^3.0.3", - "gulp-zip": "^3.0.2", - "http-proxy-middleware": "^0.9.0", - "lodash": "^3.10.1", - "main-bower-files": "^2.9.0", - "wiredep": "^2.2.2", - "wrench": "^1.5.8" + "estraverse": "~4.1.0", + "gulp": "~3.9.0", + "gulp-autoprefixer": "~3.0.2", + "gulp-angular-templatecache": "~1.8.0", + "del": "~2.0.2", + "lodash": "~3.10.1", + "gulp-minify-css": "~1.2.1", + "gulp-filter": "~3.0.1", + "gulp-flatten": "~0.2.0", + "gulp-eslint": "~1.0.0", + "eslint-plugin-angular": "~0.12.0", + "gulp-load-plugins": "~0.10.0", + "gulp-size": "~2.0.0", + "gulp-uglify": "~1.4.1", + "gulp-useref": "~1.3.0", + "gulp-util": "~3.0.6", + "gulp-ng-annotate": "~1.1.0", + "gulp-replace": "~0.5.4", + "gulp-rename": "~1.2.2", + "gulp-rev": "~6.0.1", + "gulp-rev-replace": "~0.4.2", + "gulp-minify-html": "~1.0.4", + "gulp-inject": "~3.0.0", + "gulp-protractor": "~1.0.0", + "gulp-sourcemaps": "~1.6.0", + "gulp-sass": "~2.0.4", + "gulp-angular-filesort": "~1.1.1", + "main-bower-files": "~2.9.0", + "wiredep": "~2.2.2", + "karma": "~0.13.10", + "karma-jasmine": "~0.3.6", + "karma-phantomjs-launcher": "~0.2.1", + "phantomjs": "~1.9.18", + "karma-angular-filesort": "~1.0.0", + "karma-coverage": "~0.5.2", + "karma-ng-html2js-preprocessor": "~0.2.0", + "browser-sync": "~2.9.11", + "browser-sync-spa": "~1.0.3", + "http-proxy-middleware": "~0.9.0", + "chalk": "~1.1.1", + "uglify-save-license": "~0.4.1", + "wrench": "~1.5.8" }, "scripts": { "postinstall": "bower install"