This repository was archived by the owner on Mar 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
121 lines (102 loc) · 3.38 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/**
* Created by sp-admin on 4/11/2015.
*/
var gulp = require('gulp');
var scopeCss = require("gulp-scope-css");
var rename = require('gulp-rename');
var replace = require('gulp-replace');
var concatCss = require('gulp-concat-css');
var runSequence = require('gulp-run-sequence');
var concat = require('gulp-concat');
var watch = require('gulp-watch');
var del = require('del');
var bundle = require('gulp-bundle-assets');
var cfg = require('./gulp.config.js');
/**
* Vendor section
*/
gulp.task('bsScope', function () {
return gulp.src(['./bower_components/bootstrap/dist/**/*.css', '!./bower_components/bootstrap/dist/**/*scoped*.css'])
.pipe(scopeCss('.bsScope'))
.pipe(replace(' html', '.html-bs'))
.pipe(replace(' body', '.body-bs'))
.pipe(replace('url(\'../fonts/', 'url(\'./fonts/'))
.pipe(replace('url(../fonts/', 'url(./fonts/'))
.pipe(rename(function (path) {
path.basename += '-scoped'
}))
.pipe(gulp.dest('./bower_components/bootstrap/dist/'));
});
gulp.task('xScope', function () {
return gulp.src(['./bower_components/x-editable/dist/bootstrap3-editable/css/bootstrap-editable.css'])
.pipe(scopeCss('.bsScope'))
.pipe(replace(' html', '.html-bs'))
.pipe(replace(' body', '.body-bs'))
.pipe(rename(function (path) {
path.basename += '-scoped'
}))
.pipe(gulp.dest('./bower_components/x-editable/dist/bootstrap3-editable/css/'));
});
var vendorDist = cfg.vendorDist;
gulp.task('move', function () {
return gulp.src(vendorDist) //, {base: './'} to keep folder structure
.pipe(gulp.dest('./dist/vendor'));
});
gulp.task('spVendor',function () {
return gulp.src(['./build/**/*.*', '!./build/**/*spBs*.*'])
.pipe(gulp.dest(cfg.sharePointTargetDir));
});
gulp.task('build_vendor', ['bsScope', 'xScope'], function (cb) {
runSequence('move', cb);
});
/**
* Src section
*/
gulp.task('spSrc',function () {
return gulp.src(['./build/**/*spBs*.*'])
.pipe(gulp.dest(cfg.sharePointTargetDir));
});
gulp.task('buildCss', function () {
return gulp.src('./src/style/**/*.css')
.pipe(concatCss(''))
.pipe(gulp.dest('./build/spBsCtrls.css'));
});
gulp.task('buildJs', function (cb) {
return gulp.src(['./src/js/ns.js', './src/js/**/*.js'])
.pipe(concat('spBsCtrls.js'))
.pipe(gulp.dest('./build/'));
});
/**
* Common section
*/
//Deprecated for now
//gulp.task('legacy', function () {
// return gulp.src(cfg.legacyDist)
// .pipe(gulp.dest('./build/'));
//});
gulp.task('build', function (cb) {
runSequence('build_vendor', 'buildCss', 'buildJs', cb) //'legacy'
});
gulp.task('watch', function () {
return watch(['./src/js/**/*.js', './src/style/**/*.css', './test.js'], function () {
runSequence(['buildJs', 'buildCss'], 'spSrc', 'trans');
});
});
gulp.task('clean', function (cb) {
return del(['./dist/', './build', cfg.sharePointTargetDir], {force: true}, cb)
});
gulp.task('bundle', function () {
return gulp.src('./bundle.config.js')
.pipe(bundle())
.pipe(gulp.dest('./build'))
});
gulp.task('default', function (cb) {
runSequence('clean', 'build', 'bundle', ['spSrc', 'spVendor'], cb);
});
/*
Transfer test.js to style library
*/
gulp.task('trans', function () {
return gulp.src(['./test.js'])
.pipe(gulp.dest(cfg.sharepointStyleLibrary));
})