Skip to content

Commit

Permalink
Added babel loader
Browse files Browse the repository at this point in the history
  • Loading branch information
mancioshell committed Jun 26, 2018
1 parent 8557182 commit 6ac937a
Show file tree
Hide file tree
Showing 7 changed files with 786 additions and 953 deletions.
6 changes: 6 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"presets": ["env"],
"plugins": [
"syntax-async-functions", "transform-regenerator"
]
}
1 change: 0 additions & 1 deletion export.js

This file was deleted.

47 changes: 19 additions & 28 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,22 @@
var gulp = require('gulp');
var rename = require('gulp-rename');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var uglify = require('gulp-uglify');
var babelify = require('babelify');
const gulp = require('gulp');
const gutil = require("gulp-util");
const webpack = require('webpack');
const config = require('./webpack.config.js');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')

gulp.task('default', ['build', 'watch']);

gulp.task('watch', function () {
gulp.watch('./src/*.js', ['build']);
gulp.watch('./*.js', ['build']);
const uglify = new UglifyJsPlugin({
include: /\.min.*/,
sourceMap: true
});

function build(file) {
return browserify(file, {
noParse: [require.resolve('./src/zxing')]
})
.transform(babelify, {
ignore: /zxing\.js$/i,
presets: ['es2015'],
plugins: ['syntax-async-functions', 'transform-regenerator']
})
.bundle()
.pipe(source('instascan.js'));
}
gulp.task('default', ['dev', 'watch']);

gulp.task('watch', function() {
gulp.watch('./src/*.js', ['dev']);
});

gulp.task('release', function () {
gulp.task('production', function() {
config.plugins.push(uglify)
return webpack(config, function(err, stats) {
if (err) throw new gutil.PluginError("webpack", err);
gutil.log("[webpack]", stats.toString({
Expand All @@ -38,7 +25,11 @@ gulp.task('release', function () {
});
});

gulp.task('build', function () {
return build('./export.js')
.pipe(gulp.dest('./dist/'));
gulp.task('dev', function() {
return webpack(config, function(err, stats) {
if (err) throw new gutil.PluginError("webpack", err);
gutil.log("[webpack]", stats.toString({
// output options
}));
});
});
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ require('webrtc-adapter');

var Instascan = {
Scanner: require('./src/scanner'),
Camera: require('./src/camera')
Camera: require('./src/camera'),
Zxing: require('./src/zxing')
};

module.exports = Instascan;

0 comments on commit 6ac937a

Please sign in to comment.