add gulp task "copy-server" to copy the project built, on the django server
authorrougeronj
Wed, 08 Apr 2015 00:37:52 +0200
changeset 78 aaffa46a2b79
parent 77 ee963d1c409b
child 79 1be5cc51e359
add gulp task "copy-server" to copy the project built, on the django server
client/app/index.html
client/gulpfile.js
client/package.json
--- a/client/app/index.html	Wed Apr 08 00:36:37 2015 +0200
+++ b/client/app/index.html	Wed Apr 08 00:37:52 2015 +0200
@@ -1,10 +1,17 @@
+<!-- build:django -->
+<!-- endbuild -->
+
 <!doctype html>
 <html>
 <head>
   <meta charset="utf-8">
   <title>Ammico : Home</title>
+  
+  <!-- build:css -->
   <link rel="stylesheet" href="lib.css">
   <link rel="stylesheet" href="app.css">
+  <!-- endbuild -->
+  
 </head>
 <body ng-controller="homeCtrl" ng-app="ammico" ng-cloak>
   <div class="navbar navbar-inverse" role="navigation">
@@ -16,7 +23,11 @@
             <span class="icon-bar"></span>
             <span class="icon-bar"></span>
           </button>
-          <a class="navbar-brand" id="logo" href="#/"><img src="img/ammico_logo_small.png"></a>
+          <a class="navbar-brand" id="logo" href="#/">
+          	<!-- build:imgLogo -->
+          	<img src="img/ammico_logo_small.png">
+          	<!-- endbuild -->
+          </a>
         </div>
         <div class="collapse navbar-collapse">
           <ul class="nav navbar-nav" ng-controller="routeClassCtrl">
@@ -44,7 +55,11 @@
     <footer>
       <div class="row">
         <div class="footer-img col-md-6">
-            <a href="http://www.iri.centrepompidou.fr" target="_blank"><img src="img/logo_IRI_footer.png" alt="Logo IRI" /></a>
+            <a href="http://www.iri.centrepompidou.fr" target="_blank">
+            	<!-- build:imgFooter -->
+            	<img src="img/logo_IRI_footer.png" alt="Logo IRI" />
+            	<!-- endbuild -->
+            </a>
         </div>
         <div class="col-md-6 text-right">
             ammico vBeta - ©2014
@@ -52,9 +67,13 @@
       </div>
     </footer>
   </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>
+  <!-- endbuild -->
+  
   <script type="text/javascript">
       angular.module("ammico")
           .value('context', {
--- a/client/gulpfile.js	Wed Apr 08 00:36:37 2015 +0200
+++ b/client/gulpfile.js	Wed Apr 08 00:37:52 2015 +0200
@@ -1,6 +1,7 @@
 var gulp = require('gulp');
 var gutil = require('gulp-util')
 var plugins = require("gulp-load-plugins")({lazy:false});
+var htmlreplace = require('gulp-html-replace');
 //var flatten = require('gulp-flatten');
 //var uglify = require('gulp-uglify');
 //var clean = require('gulp-clean');
@@ -116,6 +117,38 @@
         .pipe(gulp.dest('./build/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.task('watch',function(){
     gulp.watch([
         'build/**/*.html',
--- a/client/package.json	Wed Apr 08 00:36:37 2015 +0200
+++ b/client/package.json	Wed Apr 08 00:37:52 2015 +0200
@@ -20,6 +20,7 @@
     "gulp-csslint": "^0.1.4",
     "gulp-filesize": "0.0.6",
     "gulp-flatten": "0.0.2",
+    "gulp-html-replace": "^1.4.4",
     "gulp-jshint": "~1.5.0",
     "gulp-load-plugins": "~0.4.0",
     "gulp-minify-css": "^0.3.4",