forked from akveo/blur-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
devRelease.js
57 lines (48 loc) · 1.88 KB
/
devRelease.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
'use strict';
var path = require('path');
var gulp = require('gulp');
var conf = require('./conf');
var $ = require('gulp-load-plugins')({
pattern: ['gulp-*', 'main-bower-files']
});
var _ = require('lodash');
gulp.task('dev-fonts', function () {
return gulp.src($.mainBowerFiles())
.pipe($.filter('**/*.{eot,svg,ttf,woff,woff2}'))
.pipe($.flatten())
.pipe(gulp.dest(path.join(conf.paths.devDist, 'fonts')));
});
gulp.task('dev-copy-lib', function () {
var assets = require('wiredep')(_.extend({}, conf.wiredep));
var srcList = [];
srcList.push.apply(srcList, assets.js);
srcList.push.apply(srcList, assets.css);
return gulp
.src(srcList/*, { base: '.' }*/)
/* .pipe($.rename(function (p) {
p.dirname = p.dirname.replace(/\\/g, '/').replace('bower_components/', '');
if (p.dirname.indexOf('/') !== -1) {
p.dirname = p.dirname.substr(0, p.dirname.indexOf('/'));
}
}))*/
.pipe(gulp.dest(path.join(conf.paths.devDist, 'lib')));
});
gulp.task('dev-css-replace', ['dev-copy-assets'], function() {
return gulp.src(path.join(conf.paths.devDist, '*.html'))
.pipe($.replace(/<link rel="stylesheet" href="\.\.\/bower_components\/.*\/(.*)"\s*?\/>/g, '<link rel="stylesheet" href="lib/$1" >'))
.pipe(gulp.dest(conf.paths.devDist));
});
gulp.task('dev-js-replace', ['dev-copy-assets'], function() {
return gulp.src(path.join(conf.paths.devDist, '.html'))
.pipe($.replace(/<script src="\.\.\/bower_components\/.*\/(.*)"\s*?>/g, '<script src="lib/$1">'))
.pipe(gulp.dest(conf.paths.devDist));
});
gulp.task('dev-copy-assets', ['inject', 'dev-copy-lib', 'dev-fonts'], function () {
return gulp
.src([
conf.paths.src + '/**/*',
path.join(conf.paths.tmp, '/serve/**/*')
])
.pipe(gulp.dest(conf.paths.devDist));
});
gulp.task('dev-release', ['dev-css-replace', 'dev-js-replace']);