Skip to content

Commit 8892d56

Browse files
IegorKozakovdimaspirit
authored andcommitted
remove jQuery or Zepto dependency (#173)
* add a jquery.ajax as plugin
1 parent 024fa67 commit 8892d56

File tree

7 files changed

+5309
-88356
lines changed

7 files changed

+5309
-88356
lines changed

.jshintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/plugins/jquery.ajax.js

gulpfile.js

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ var source = require('vinyl-source-stream');
88
var connect = require('gulp-connect');
99
var notify = require('gulp-notify');
1010

11+
var uglify = require('gulp-uglify');
12+
var pump = require('pump');
13+
14+
var fs = require('fs');
15+
var builder = require('jquery-custom');
16+
1117
gulp.task('build', function () {
1218
var isDevelopment = process.env.NODE_ENV === 'develop',
1319
browserifyOpts = {
@@ -18,12 +24,21 @@ gulp.task('build', function () {
1824
return browserify('./src/qbMain.js', browserifyOpts)
1925
.bundle()
2026
.on('error', function(error) {
21-
notify('Failed when create a bundle <%= error.message %>')
27+
notify('Failed when create a bundle <%= error.message %>');
2228
this.emit('end');
2329
})
2430
.pipe(source('quickblox.min.js'))
25-
.pipe(notify('Build task is finished.'))
26-
.pipe(gulp.dest('./'));
31+
.pipe(gulp.dest('./'))
32+
.pipe(notify('Build task is finished.'));
33+
});
34+
35+
gulp.task('minify', function () {
36+
pump([
37+
gulp.src('./quickblox.min.js'),
38+
uglify(),
39+
notify('Minify task is finished.'),
40+
gulp.dest('./')
41+
]);
2742
});
2843

2944
gulp.task('connect', function() {
@@ -57,6 +72,38 @@ gulp.task('generate-build_version', function() {
5772
});
5873
});
5974

75+
gulp.task('jquery', function () {
76+
return builder({
77+
flags: [
78+
'-deprecated',
79+
'-dimensions',
80+
'-effects',
81+
'-event',
82+
'-event/alias',
83+
'-event/focusin',
84+
'-event/trigger',
85+
'-offset',
86+
'-wrap',
87+
'-core/ready',
88+
'-exports/global',
89+
'-sizzle'
90+
],
91+
}, function (err, compiledContent) {
92+
if (err){
93+
notify('Can\'t build jquery lib.');
94+
return console.error(err);
95+
}
96+
97+
fs.writeFile('./src/plugins/jquery.ajax.js', compiledContent, function (err) {
98+
if (err){
99+
notify('Can\'t build jquery lib.');
100+
return console.error(err);
101+
}
102+
notify('Jquery task is finished.');
103+
})
104+
})
105+
});
106+
60107
gulp.task('watch', function () {
61108
gulp.watch(['./src/**/*.js'], ['build']);
62109
});

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,12 @@
5252
"gulp": "^3.9.1",
5353
"gulp-connect": "^5.0.0",
5454
"gulp-notify": "^2.2.0",
55+
"gulp-uglify": "^2.0.0",
5556
"jasmine": "^2.4.1",
57+
"jquery-custom": "^1.1.1",
5658
"jshint": "^2.9.3",
5759
"jshint-stylish": "^2.2.1",
60+
"pump": "^1.0.1",
5861
"vinyl-source-stream": "^1.1.0"
5962
},
6063
"autoupdate": {
@@ -74,7 +77,7 @@
7477
"scripts": {
7578
"setDependencies": "npm i && npm install -g gulp-cli && npm install -g jasmine",
7679
"lint": "jshint src --reporter=node_modules/jshint-stylish",
77-
"build": "npm run lint && gulp generate-build_version && gulp build",
80+
"build": "npm run lint && gulp generate-build_version && gulp build && gulp minify",
7881
"develop": "cross-env NODE_ENV=develop gulp",
7982
"start": "gulp connect"
8083
}

0 commit comments

Comments
 (0)