Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added webpack module bundler to generate umd module #159

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
]
}
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
language: node_js
- '6'
install: npm install
script: gulp release
before_script:
- npm install -g gulp-cli
script: gulp production
env:
global:
- COMMIT_AUTHOR_NAME: "'Chris Schmich'"
- COMMIT_AUTHOR_EMAIL: 'schmch@gmail.com'
- ENCRYPTION_LABEL: 95f025fe7ce3
deploy:
deploy:
provider: script
script: bash ./deploy/deploy.sh
skip_cleanup: true
Expand Down
1 change: 0 additions & 1 deletion export.js

This file was deleted.

61 changes: 28 additions & 33 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,35 @@
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 () {
return build('./export.js')
.pipe(buffer())
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('./dist/'));
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({
// output options
}));
});
});

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;
Loading