Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import watchify from 'watchify';
import exorcist from 'exorcist';
import browserify from 'browserify';
import browserSync from 'browser-sync';
import sass from 'gulp-sass';
// Browsersync Reload
const reload = browserSync.reload;
// Input file.
watchify.args.debug = true;
// let bundler = watchify(browserify('app/client.js', watchify.args));
let bundler = browserify('app/client.js', watchify.args);
// Babel transform
bundler.transform(babelify.configure({
sourceMapRelative: 'app'
}));
// On updates recompile
bundler.on('update', bundle);
function bundle() {
gutil.log('Compiling JS...');
return bundler.bundle()
.on('error', (err) => {
gutil.log(err.message);
browserSync.notify('Browserify Error!');
this.emit('end');
})
function browserifyBundler() {
// Our browserify bundle is made up of our unit tests, which
// should individually load up pieces of our application.
// We also include the browserify setup file.
const testFiles = glob.sync('./test/unit/**/*.js');
const allFiles = ['./test/setup/browserify.js'].concat(testFiles);
// Create our bundler, passing in the arguments required for watchify
watchify.args.debug = true;
const bundler = browserify(allFiles, watchify.args);
// Set up Babelify so that ES6 works in the tests
bundler.transform(babelify.configure({
sourceMapRelative: __dirname + '/src'
}));
return bundler;
}
function getBundler(isDev) {
var bundler = browserify({
entries: ['./src/js/App.jsx'],
extensions: ['.js', '.jsx'],
debug: isDev,
cache: {}, // for watchify
packageCache: {}, // for watchify
fullPaths: true // for watchify
});
bundler.transform(babelify.configure({
optional: []
}));
return bundler;
}
function compile(watch) {
var bundler = watchify(browserify('./src/linemate.js', { debug: true }).transform(babelify.configure({
plugins: ['object-assign']
})));
function rebundle() {
bundler.bundle()
.on('error', function(err) { console.error(err); this.emit('end'); })
.pipe(source('linemate.min.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist'))
.pipe(gulp.dest('./demo'));
}
if (watch) {
function compile(watch) {
var bundler = watchify(browserify('./src/main.ts', { debug: true }).plugin(tsify, {target: 'es6'}).transform(babelify.configure({extensions: [".ts",".js"]})));
function rebundle() {
bundler.bundle()
.on('error', function(err) { console.error(err); this.emit('end'); })
.pipe(source('trees.bundle.js'))
.pipe(buffer())
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist'));
}
if (watch) {
gulp.watch('./src/**').on("change", function() {
console.log('-> bundling...');
rebundle();
});
function compile(watch) {
var bundler = watchify(
browserify('./src/react-bootstrap-toggle.js', { debug: true })
.transform(babel.configure({presets: ["es2015", "react"]}))
);
function rebundle() {
bundler.bundle()
.on('error', function(err) { console.error(err); this.emit('end'); })
.pipe(source('react-bootstrap-toggle.js'))
.pipe(buffer())
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(sourcemaps.write('./dist'))
.pipe(gulp.dest('./dist'));
}
if (watch) {
bundler.on('update', function() {
console.log('-> bundling...');
rebundle();
gulp.task('bundle', function () {
var filePath = './src/plugin.js';
var extensions = ['.js'];
var bundler = browserify({
entries: [filePath],
extensions: extensions,
debug: false
});
bundler.transform(babelify.configure({
presets: ["es2015"],
plugins: [["babel-plugin-sketch-manifest-processor", ManifestProcessorOptions]]
}));
return bundler.bundle()
.on('error',(function(arg) {
console.log(arg.message);
}))
.pipe(source(ManifestProcessorOptions.scriptFileName))
.pipe(gulp.dest('./build/'));
});
frameworks: ['mocha', 'browserify', 'fixture'],
files: [
'./node_modules/babel-polyfill/dist/polyfill.js',
'test/*.js',
'test/fixtures.html',
],
exclude: [
],
browserify: {
debug: true,
extensions: ['.js'],
transform: [
require('babelify').configure({
plugins: ['babel-plugin-espower'],
}),
],
},
preprocessors: {
'test/*.html': 'html2js',
'test/*.js': ['browserify'],
},
reporters: ['progress'],
port: 9876,
colors: true,
gulp.task('build', function () {
const browserifyOptions = {
entries: ['./src/paginated-redux'],
debug: false,
fullPaths: false
};
const babelifyOptions = {
presets: ['es2015'],
plugins: [
'transform-object-rest-spread',
'transform-es2015-modules-commonjs'
]
};
const stream = browserify(browserifyOptions)
.transform(babelify.configure(babelifyOptions));
return stream
.bundle()
.pipe(source('paginated-redux.min.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest('./dist'));
});