-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
47 lines (42 loc) · 1.26 KB
/
Copy pathgulpfile.js
File metadata and controls
47 lines (42 loc) · 1.26 KB
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
var gulp = require('gulp'),
browserify = require('gulp-browserify'),
concat = require('gulp-concat'),
replace = require('gulp-replace'),
uglify = require('gulp-uglify'),
util = require('gulp-util'),
pump = require('pump');
var jsSrc = 'js/src/index.js';
var jsDst = 'js/dist';
var fileName = 'paragraphseditor';
gulp.task('scripts', function(cb) {
var s = gulp.src(jsSrc)
.pipe(browserify({
debug: !util.env.production,
}))
.on('prebundle', function(bundle) {
bundle.exclude('jquery');
bundle.exclude('underscore');
bundle.exclude('backbone');
bundle.exclude('drupal');
bundle.exclude('drupal-settings');
})
.pipe(replace(/require\('jquery'\)/g, 'window.jQuery '))
.pipe(replace(/require\('underscore'\)/g, 'window._ '))
.pipe(replace(/require\('backbone'\)/g, 'window.Backbone '))
.pipe(replace(/require\('drupal'\)/g, 'window.Drupal '))
.pipe(replace(/require\('drupal-settings'\)/g, 'window.drupalSettings '))
.pipe(concat(fileName + '.js'))
if (util.env.production) {
pump([
s,
uglify(),
gulp.dest(jsDst),
], cb);
}
else {
s.pipe(gulp.dest(jsDst));
}
});
gulp.task('watch', function() {
gulp.watch(jsSrc, ['scripts']);
});