-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
46 lines (39 loc) · 1.13 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
var intercept = require('gulp-intercept');
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var webpack = require('webpack-stream');
var config = require('./webpack.config');
// 1. this function, must return production ready scripts
module.exports = function(businessId, done) {
var babelotBusinessId = businessId;
config.module.loaders.push({
test: /\.js?$/,
exclude: /(node_modules)/,
loader: `imports?babelotBusinessId=>'${babelotBusinessId}'`
});
gulp.src('src/index.js')
.pipe(webpack(config))
.pipe(uglify())
.pipe(intercept((file)=> {
config.module.loaders.pop();
done(file.contents.toString());
}))
};
gulp.task('watch', ()=> {
gulp.watch('./src/**/*', ['default'])
});
var babelotBusinessId = 'ExclusiveRentals.com'
config.module.loaders.push({
test: /\.js?$/,
exclude: /(node_modules)/,
loader: `imports?babelotBusinessId=>'${babelotBusinessId}'`
});
gulp.task('default', function() {
return gulp.src('src/index.js')
.pipe(webpack(config))
.pipe(uglify())
.pipe(intercept((file)=> {
return file;
}))
.pipe(gulp.dest('./build'))
});