mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2026-02-04 00:06:19 +08:00
This just might work
This commit is contained in:
61
gulpfile.js
61
gulpfile.js
@@ -1,24 +1,55 @@
|
||||
var gulp = require("gulp");
|
||||
sourcemaps = require("gulp-sourcemaps"),
|
||||
babel = require("gulp-babel"),
|
||||
var gulp = require("gulp"),
|
||||
source = require('vinyl-source-stream'),
|
||||
buffer = require('vinyl-buffer'),
|
||||
sourcemaps = require("gulp-sourcemaps"),
|
||||
concat = require("gulp-concat"),
|
||||
connect = require('gulp-connect');
|
||||
connect = require('gulp-connect'),
|
||||
browserify = require('browserify'),
|
||||
watchify = require('watchify'),
|
||||
babel = require('babelify');
|
||||
|
||||
gulp.task("default", ['build'], function () {
|
||||
});
|
||||
|
||||
function compile(watch) {
|
||||
var bundler = watchify(browserify()
|
||||
.require('./src/index.js', {
|
||||
entry: true,
|
||||
expose: 'ionic-native'
|
||||
})
|
||||
.transform(babel, {presets: ['es2015']}));
|
||||
|
||||
function rebundle() {
|
||||
bundler.bundle()
|
||||
.on('error', function(err) { console.error(err); this.emit('end'); })
|
||||
.pipe(source('ionic-native.js'))
|
||||
.pipe(buffer())
|
||||
.pipe(sourcemaps.init({ loadMaps: true }))
|
||||
.pipe(sourcemaps.write('./'))
|
||||
.pipe(gulp.dest('./dist'));
|
||||
}
|
||||
|
||||
if (watch) {
|
||||
bundler.on('update', function() {
|
||||
console.log('-> bundling...');
|
||||
rebundle();
|
||||
});
|
||||
}
|
||||
|
||||
rebundle();
|
||||
}
|
||||
|
||||
function watch() {
|
||||
return compile(true);
|
||||
}
|
||||
|
||||
gulp.task("default", ['build'], function () { });
|
||||
|
||||
gulp.task('build', function() {
|
||||
return gulp.src("src/**/*.js")
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(babel())
|
||||
.pipe(concat("ionic-native.js"))
|
||||
.pipe(sourcemaps.write("."))
|
||||
.pipe(gulp.dest("dist"));
|
||||
return compile();
|
||||
});
|
||||
|
||||
gulp.task('test', ['build', 'serve'], function() {
|
||||
|
||||
})
|
||||
gulp.task('watch', function() {
|
||||
return watch();
|
||||
});
|
||||
|
||||
gulp.task('serve', function() {
|
||||
connect.server({
|
||||
|
||||
Reference in New Issue
Block a user