-
Notifications
You must be signed in to change notification settings - Fork 322
/
gulpfile.js
83 lines (72 loc) · 2.44 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
var coffeescript = require('coffee-script/register');
var path = require('path');
var Mincer = require('mincer');
var gulp = require('gulp');
var clean = require('gulp-clean');
var concat = require('gulp-concat');
var ext_replace = require('gulp-ext-replace');
var cleaning = require('gulp-initial-cleaning');
var minCSS = require('gulp-minify-css');
var uglify = require('gulp-uglify');
var remoteSrc = require('gulp-remote-src');
var minifyHTML = require('gulp-minify-html');
var mince = require('gulp-mincer');
var environment = new Mincer.Environment();
var ngTemplatesEngine = require('./app/back/lib/ngtemplate.coffee');
var server;
var DIST_DIR = "dist";
var ASSETS_DIR = DIST_DIR + "/assets";
var ASSETS_PATH = ["app/front/js", "app/front/css", "bower_components"];
var ASSETS = {
external_scripts: "app/front/js/*.js",
scripts: "app/front/js/*.coffee",
styles: "app/front/css/*.less"
};
environment.registerEngine('.html', ngTemplatesEngine);
environment.appendPath(ASSETS_PATH);
cleaning({tasks: ['default'], folders: ['dist']});
gulp.task('js-ext', function() {
return gulp.src(ASSETS.external_scripts)
.pipe(mince(environment))
.pipe(uglify())
.pipe(gulp.dest(ASSETS_DIR));
});
gulp.task('js', function() {
return gulp.src(ASSETS.scripts)
.pipe(mince(environment))
.pipe(uglify())
.pipe(ext_replace('.js'))
.pipe(gulp.dest(ASSETS_DIR));
});
gulp.task('css', function() {
return gulp.src(ASSETS.styles)
.pipe(mince(environment))
.pipe(minCSS())
.pipe(ext_replace('.css'))
.pipe(gulp.dest(ASSETS_DIR));
});
gulp.task('html', function() {
process.env.NODE_ENV = 'production';
var app = require('./app/back/app.coffee');
server = app.listen(9898);
var opts = {
conditionals: true,
spare: true,
loose: true
};
return remoteSrc(['/'], { base: 'http://localhost:9898' })
.pipe(concat('index.html'))
.pipe(minifyHTML(opts))
.pipe(gulp.dest(DIST_DIR));
});
gulp.task('static-assets', function() {
gulp.src([
'app/front/public/**',
'!app/front/public/assets{,/**}'
]).pipe(gulp.dest(DIST_DIR));
});
gulp.task('default', ['js-ext', 'js', 'css', 'html', 'static-assets'], function() {
var cleanups = ['app/front/public/assets', 'production.log'];
gulp.src(cleanups, {read: false}).pipe(clean());
server.close();
});