updates dependencies and add main-bower-file to gulpfile to concatenate the vendorJs
authorrougeronj
Thu, 21 May 2015 11:07:34 +0200
changeset 88 2db951a4a04c
parent 87 7b43de480a11
child 89 7faa53118457
updates dependencies and add main-bower-file to gulpfile to concatenate the vendorJs Refactors gulpfile
client/app/index.html
client/bower.json
client/gulpfile.js
client/package.json
--- a/client/app/index.html	Thu Apr 23 18:17:58 2015 +0200
+++ b/client/app/index.html	Thu May 21 11:07:34 2015 +0200
@@ -8,8 +8,8 @@
   <title>Ammico : Home</title>
   
   <!-- build:css -->
-  <link rel="stylesheet" href="lib.css">
-  <link rel="stylesheet" href="app.css">
+  <link rel="stylesheet" href="css/lib.css">
+  <link rel="stylesheet" href="css/app.css">
   <!-- endbuild -->
   
 </head>
@@ -23,7 +23,7 @@
             <span class="icon-bar"></span>
             <span class="icon-bar"></span>
           </button>
-          <a class="navbar-brand" id="logo" href="#/">
+          <a class="navbar-brand logo" href="#/">
           	<!-- build:imgLogo -->
           	<img src="img/ammico_logo_small.png">
           	<!-- endbuild -->
@@ -69,9 +69,9 @@
   </div>
   
   <!-- build:js -->
-  <script type="text/javascript" src="lib.js"></script>
-  <script type="text/javascript" src="templates.js"></script>
-  <script type="text/javascript" src="app.js"></script>
+  <script type="text/javascript" src="js/lib.js"></script>
+  <script type="text/javascript" src="js/templates.js"></script>
+  <script type="text/javascript" src="js/app.js"></script>
   <!-- endbuild -->
   
   <script type="text/javascript">
--- a/client/bower.json	Thu Apr 23 18:17:58 2015 +0200
+++ b/client/bower.json	Thu May 21 11:07:34 2015 +0200
@@ -14,7 +14,7 @@
     "test",
     "tests"
   ],
-  "devDependencies": {
+  "dependencies": {
     "angular": "~1.3",
     "angular-route": "~1.3",
     "angular-resource": "~1.3",
--- a/client/gulpfile.js	Thu Apr 23 18:17:58 2015 +0200
+++ b/client/gulpfile.js	Thu May 21 11:07:34 2015 +0200
@@ -1,21 +1,23 @@
 var gulp = require('gulp');
 var gutil = require('gulp-util')
 var plugins = require("gulp-load-plugins")({lazy:false});
+var mainBowerFiles = require('main-bower-files');
 var htmlreplace = require('gulp-html-replace');
-//var flatten = require('gulp-flatten');
-//var uglify = require('gulp-uglify');
-//var clean = require('gulp-clean');
-//var rename = require('gulp-rename');
-//var filesize = require('gulp-filesize');
-//var cssmin  = require('gulp-cssmin');
 
-gulp.task('clean', function () {
-  return gulp.src('build', {read: false})
-    .pipe(clean());
-});
+var templateFolder = './../server/ammico';
+var staticFolder = './../server/ammico/static/ammico';
+var buildFolder = './build';
 
 var scriptsSrc = ['!./app/**/*_test.js','./app/**/*.js'];
 
+gulp.task('templates',function(){
+    //combine all template files of the app into a js file
+    gulp.src(['!./app/index.html',
+        './app/**/*.html'])
+        .pipe(plugins.angularTemplatecache('templates.js',{standalone:true}))
+        .pipe(gulp.dest(buildFolder+'/js'));
+});
+
 gulp.task('scripts', function(){
     //combine all js files of the app
     gulp.src(scriptsSrc)
@@ -23,62 +25,33 @@
         .pipe(plugins.jshint.reporter('default'))
         .pipe(plugins.jshint.reporter('fail'))
         .pipe(plugins.concat('app.js'))
-        .pipe(gulp.dest('./build'))
-        .pipe(plugins.filesize())
-        .pipe(plugins.uglify())
-        .pipe(plugins.rename('app.min.js'))
-        .pipe(gulp.dest('./build'))
+        .pipe(gulp.dest(buildFolder+'/js'))
         .pipe(plugins.filesize())
         .on('error', gutil.log);
 });
 
-gulp.task('templates',function(){
-    //combine all template files of the app into a js file
-    gulp.src(['!./app/index.html',
-        './app/**/*.html'])
-        .pipe(plugins.angularTemplatecache('templates.js',{standalone:true}))
-        .pipe(gulp.dest('./build'));
-});
-
 gulp.task('css', function(){
     gulp.src('./app/**/*.css')
-//        .pipe(plugins.csslint())
-//        .pipe(plugins.csslint.reporter())
+        .pipe(plugins.csslint({ 'box-sizing': false }))
+        .pipe(plugins.csslint.reporter())
         .pipe(plugins.concat('app.css'))
-        .pipe(gulp.dest('./build'))
-        .pipe(plugins.filesize())
-        .pipe(plugins.minifyCss({keepBreaks:true}))
-        .pipe(plugins.rename('app.min.css'))
-        .pipe(gulp.dest('./build'))
+        .pipe(gulp.dest(buildFolder+'/css'))
         .pipe(plugins.filesize());
 });
 
-var vendorJSsrc = [
-  '!./bower_components/**/*.min.js',
-  '!./bower_components/bootstrap/**/*',
-  '!./bower_components/jquery/src/**/*',
-  '!./bower_components/jquery-ui/themes/**',
-  '!./bower_components/jquery-ui/ui/**',
-  '!./bower_components/jquery-ui/ui/*.js',
-  '!./bower_components/**/index.js',
-  './bower_components/bootstrap/dist/css/*',
-  './bower_components/jquery/dist/jquery.js',
-  './bower_components/angular/angular.js',
-  './bower_components/angular-route/angular-route.js',
-  './bower_components/angular-resource/angular-resource.js',
-  './bower_components/angular-bootstrap/ui-bootstrap.js',
-  './bower_components/**/*.js'
-];
-
 gulp.task('vendorJS', function(){
     //concatenate vendor JS files
-    gulp.src(vendorJSsrc)
+    return gulp.src(mainBowerFiles('**/*.js', {
+            "overrides":{
+                "angular": {
+                    "dependencies": {
+                        "jquery": "~1.8"
+                    }
+                }
+            }
+        }))
         .pipe(plugins.concat('lib.js'))
-        .pipe(gulp.dest('./build'))
-        .pipe(plugins.filesize())
-        .pipe(plugins.uglify())
-        .pipe(plugins.rename('lib.min.js'))
-        .pipe(gulp.dest('./build'))
+        .pipe(gulp.dest(buildFolder+'/js'))
         .pipe(plugins.filesize())
         .on('error', gutil.log);
 });
@@ -88,18 +61,37 @@
     gulp.src(['!./bower_components/**/*.min.css',
         './bower_components/**/*.css'])
         .pipe(plugins.concat('lib.css'))
-        .pipe(gulp.dest('./build'))
-        .pipe(plugins.filesize())
-        .pipe(plugins.minifyCss({keepBreaks:true}))
-        .pipe(plugins.rename('lib.min.css'))
-        .pipe(gulp.dest('./build'))
+        .pipe(gulp.dest(buildFolder+'/css'))
         .pipe(plugins.filesize());
 });
 
 gulp.task('vendorFonts', function(){
     gulp.src(['./bower_components/**/fonts/*'])
         .pipe(plugins.flatten())
-        .pipe(gulp.dest('./build/fonts'));
+        .pipe(gulp.dest(buildFolder+'/fonts'));
+});
+
+gulp.task('minimify', function(){
+    gulp.src(buildFolder+'/js/lib.js')
+        .pipe(plugins.uglify())
+        .pipe(plugins.rename('lib.min.js'))
+        .pipe(gulp.dest(buildFolder+'/js'))
+        .pipe(plugins.filesize());
+    gulp.src(buildFolder+'/js/app.js')
+        .pipe(plugins.uglify())
+        .pipe(plugins.rename('app.min.js'))
+        .pipe(gulp.dest(buildFolder+'/js'))
+        .pipe(plugins.filesize());
+    gulp.src(buildFolder+'/css/app.css')
+        .pipe(plugins.minifyCss({keepBreaks:true, processImport: false}))
+        .pipe(plugins.rename('app.min.css'))
+        .pipe(gulp.dest(buildFolder+'/css'))
+        .pipe(plugins.filesize());
+    gulp.src(buildFolder+'/css/lib.css')
+        .pipe(plugins.minifyCss({keepBreaks:true, processImport: false}))
+        .pipe(plugins.rename('lib.min.css'))
+        .pipe(gulp.dest(buildFolder+'/css'))
+        .pipe(plugins.filesize());
 });
 
 gulp.task('copy-index', function() {
@@ -109,51 +101,51 @@
 
 gulp.task('copy-data', function() {
     gulp.src('./data/**/*')
-        .pipe(gulp.dest('./build/data'));
+        .pipe(gulp.dest(buildFolder+'/data'));
 });
 
 gulp.task('copy-img', function() {
     gulp.src('./img/**/*')
-        .pipe(gulp.dest('./build/img'));
+        .pipe(gulp.dest(buildFolder+'/img'));
 });
 
 gulp.task('copy-server', function() {
-    gulp.src('./build/img/**/*')
-        .pipe(gulp.dest('./../server/ammico/static/ammico/img'));
-    gulp.src('./build/fonts/**/*')
-		.pipe(gulp.dest('./../server/ammico/static/ammico/fonts'));
-    gulp.src('./build/*.js')
-    	.pipe(gulp.dest('./../server/ammico/static/ammico/js'));
-    gulp.src('./build/*.css')
-    	.pipe(gulp.dest('./../server/ammico/static/ammico/css'));
-    gulp.src('./app/index.html')
-	    .pipe(htmlreplace({
-	    	django: '{% load static %}',
-	    	js:{
-	    		src: ['lib.js', 'templates.js', 'app.js'],
-	    		tpl: '<script src="{% static \'ammico/js/%s\' %}"></script>'
-	    	},
-	    	css: {
-	    		src: ['lib.css', 'app.css'],
-	    		tpl: '<link rel="stylesheet" type="text/css" href="{% static \'ammico/css/%s\' %}"/>'
-	    	},
-	    	imgLogo: {
-	    		src: 'ammico_logo_small.png',
-	    		tpl: '<img src="{% static \'ammico/img/%s\' %}">'
-	    	},
-	    	imgFooter: {
-	    		src: 'logo_IRI_footer.png',
-	    		tpl: '<img src="{% static \'ammico/img/%s\' %}" alt="Logo IRI" />'
-	    	}
-	    }))
-    .pipe(gulp.dest('./../server/ammico/templates'));
+    gulp.src(buildFolder+'/img/**/*')
+        .pipe(gulp.dest(staticFolder+'/img'));
+    gulp.src(buildFolder+'/fonts/**/*')
+        .pipe(gulp.dest(staticFolder+'/fonts'));
+    gulp.src(buildFolder+'/js/*.js')
+        .pipe(gulp.dest(staticFolder+'/js'));
+    gulp.src(buildFolder+'/css/*.css')
+        .pipe(gulp.dest(staticFolder+'/css'));
+    gulp.src(buildFolder+'/index.html')
+        .pipe(htmlreplace({
+            django: '{% load static %}',
+            js:{
+                src: ['lib.js', 'templates.js', 'app.js'],
+                tpl: '<script src="{% static \'ammico/js/%s\' %}"></script>'
+            },
+            css: {
+                src: ['lib.css', 'app.css'],
+                tpl: '<link rel="stylesheet" type="text/css" href="{% static \'ammico/css/%s\' %}"/>'
+            },
+            imgLogo: {
+                src: 'ammico_logo_small.png',
+                tpl: '<img src="{% static \'ammico/img/%s\' %}">'
+            },
+            imgFooter: {
+                src: 'logo_IRI_footer.png',
+                tpl: '<img src="{% static \'ammico/img/%s\' %}" alt="Logo IRI" />'
+            }
+        }))
+    .pipe(gulp.dest(templateFolder+'/templates'));
 });
 
 gulp.task('watch',function(){
     gulp.watch([
-        'build/**/*.html',
-        'build/**/*.js',
-        'build/**/*.css'
+        buildFolder+'/**/*.html',
+        buildFolder+'/**/*.js',
+        buildFolder+'/**/*.css'
     ], function(event) {
         return gulp.src(event.path)
             .pipe(plugins.connect.reload());
@@ -164,13 +156,17 @@
     gulp.watch('./app/index.html',['copy-index']);
     gulp.watch('./data/**/*',['copy-data']);
     gulp.watch('./img/**/*',['copy-img']);
-
 });
 
-gulp.task('connect', plugins.connect.server({
-    root: ['build'],
-    port: 9000,
-    livereload: true
-}));
 
-gulp.task('default',['connect','scripts','templates','css','copy-index','copy-data','copy-img','vendorJS','vendorCSS','vendorFonts','watch']);
+gulp.task('connect', function() {
+    plugins.connect.server({
+        root: buildFolder,
+    	port: 9000,
+        livereload: true
+    });
+});
+
+gulp.task('default',['connect','scripts','css', 'templates','copy-index','copy-data','copy-img','vendorJS','vendorCSS','vendorFonts','watch']);
+gulp.task('copy-server',['scripts','css', 'templates','copy-index','copy-data','copy-img','vendorJS','vendorCSS','vendorFonts','minimify','copy-server']);
+
--- a/client/package.json	Thu Apr 23 18:17:58 2015 +0200
+++ b/client/package.json	Thu May 21 11:07:34 2015 +0200
@@ -10,25 +10,26 @@
   "author": "IRI",
   "license": "Cecill-C",
   "devDependencies": {
-    "bower": "^1.3.4",
+    "bower": "^1.3.12",
     "grunt-cli": "^0.1.13",
-    "gulp": "~3.5.5",
-    "gulp-angular-templatecache": "^1.1.0",
-    "gulp-clean": "^0.3.0",
-    "gulp-concat": "~2.1.7",
-    "gulp-connect": "^1.0.7",
-    "gulp-csslint": "^0.1.4",
+    "gulp": "~3.8.8",
+    "gulp-angular-templatecache": "^1.4.2",
+    "gulp-concat": "~2.4.1",
+    "gulp-connect": "^2.2.0",
+    "gulp-csslint": "^0.1.5",
     "gulp-filesize": "0.0.6",
-    "gulp-flatten": "0.0.2",
+    "gulp-flatten": "0.0.4",
     "gulp-html-replace": "^1.4.4",
-    "gulp-jshint": "~1.5.0",
-    "gulp-load-plugins": "~0.4.0",
-    "gulp-minify-css": "^0.3.4",
+    "gulp-jshint": "~1.8.5",
+    "gulp-load-plugins": "~0.7.0",
+    "gulp-minify-css": "^0.3.10",
     "gulp-rename": "^1.2.0",
-    "gulp-uglify": "^0.3.0",
-    "gulp-util": "^2.2.16",
-    "karma": "^0.12.1",
-    "karma-chrome-launcher": "^0.1.2",
-    "karma-jasmine": "^0.1.5"
+    "gulp-uglify": "^1.0.1",
+    "gulp-util": "^3.0.1",
+    "gulp-webserver": "^0.8.3",
+    "karma": "^0.12.23",
+    "karma-chrome-launcher": "^0.1.4",
+    "karma-jasmine": "^0.1.5",
+    "main-bower-files": "^2.8.0"
   }
 }