Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function compile(watch) {
// Create our browserify instance
const bundler = watchify(browserify(config.watchify.fileIn, {debug: true}).transform(babelify));
function rebundle() {
bundler.bundle()
.on('error', function (err) {
console.error(err);
this.emit('end');
})
// Grab our entry file
.pipe(source(config.watchify.fileOut))
// Buffer it.. (?)
.pipe(buffer())
// Initialise source maps, load the maps from browserify
.pipe($.sourcemaps.init({loadMaps: true}))
function buildScript(file) {
let bundler = browserify({
entries: ['./src/app.js', configuraionFile],
debug: true, //createSourcemap(),
cache: {},
packageCache: {},
fullPaths: isDevMode // isDevMode
});
if ( isDevMode ) {
bundler = watchify(bundler);
bundler.on('update', function() {
rebundle();
gutil.log('Rebundle...');
});
}
const transforms = [
{ 'name': babelify, 'options': {}},
// { 'name':debowerify, 'options': {}},
{ 'name': ngAnnotate, 'options': {}},
{ 'name': uglifyify, 'options': { global: true }, production: true }
// { 'name':'brfs', 'options': {}},
// { 'name':' bulkify', 'options': {}}
];
runSequence('clean', ['compile'], callback)
})
gulp.task('compile', () => {
return gulp.src('src/**/*.js')
.pipe(babel())
.pipe(gulp.dest('dist'))
})
gulp.task('publish-github-pages', ['compile-example:styles', 'compile-example:scripts'], () => {
return gulp
.src('example/**/*')
.pipe(githubPages())
})
const bundler = watchify(browserify({
...watchify.args,
entries: ['./example/scripts/index.js'],
debug: true,
transform: [babelify]
}))
function bundle () {
return bundler.bundle()
.on('error', function ({ message }) {
gutil.log(gutil.colors.red('Error'), message)
})
.pipe(source('app.js'))
.pipe(buffer())
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./example'))
export default function compile(prod, watch, sync) {
if (prod) {
bundler.transform('stripify');
}
if (watch) {
bundler = watchify(bundler);
if (sync) {
browserSync.init({
proxy: "localhost:" + args.port || 8000
});
}
bundler.on('update', () => {
const msg = 'Lava.js re-bundling...';
log(green(msg));
notifier.notify({
title: 'Browserify',
message: msg
});
gulp.task('watchify', () => {
let bundler = watchify(browserify(opts));
function rebundle() {
return bundler.bundle()
.on('error', notify.onError())
.pipe(source(paths.bundle))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(paths.distJs))
.pipe(reload({stream: true}));
}
bundler.transform(babelify)
.on('update', rebundle);
return rebundle();
});
let bundler = browserify({
entries: [config.sourceDir + 'js/' + file],
debug: !global.isProd,
cache: {},
packageCache: {},
fullPaths: global.isProd ? false : true
});
bundler.require('./node_modules/log4js/lib/appenders/stdout.js', { expose: 'stdout' })
bundler.require('./node_modules/log4js/lib/appenders/console.js', { expose: 'console' })
bundler.require('./app/js/utils/log4js/portal-appender.js', { expose: 'portal-appender' })
if ( watch ) {
bundler = watchify(bundler);
bundler.on('update', rebundle);
}
bundler.transform(babelify);
if (global.isWindows) {
gutil.log('Marking as windowsBuild')
bundler.transform('browserify-replace', {replace : [ { from: 'isWindowsBuildCompileFlag = false', to: 'isWindowsBuildCompileFlag = true' } ]})
}
if (global.isWebApp) {
gutil.log('Marking as webapp build')
bundler.transform('browserify-replace', {replace : [ { from: 'isWebAppBuildCompileFlag = false', to: 'isWebAppBuildCompileFlag = true' } ]})
}
bundler.transform(debowerify);
function createBundle(
{ entries, output, destination, cssOutput },
{ watch = false, production = false },
) {
const b = watch
? watchify(
browserify({ ...watchify.args, ...browserifySettings, entries }),
).on('update', bundle)
: browserify({ ...browserifySettings, entries })
b.plugin(tsify)
b.transform(babelify, { extensions: ['.js', '.jsx', '.ts', '.tsx'] })
b.transform(
envify({
NODE_ENV: production ? 'production' : 'development',
PIWIK_HOST: production
? 'https://analytics.worldbrain.io'
: 'http://localhost:1234',
PIWIK_SITE_ID: '1',
SENTRY_DSN: production
? 'https://205014a0f65e4160a29db2935250b47c@sentry.io/305612'
: undefined,
}),
function buildScript(file, watch) {
let bundler = browserify({
entries: [config.sourceDir + 'js/' + file],
debug: !global.isProd,
cache: {},
packageCache: {},
fullPaths: global.isProd ? false : true
});
if ( watch ) {
bundler = watchify(bundler);
bundler.on('update', rebundle);
}
bundler.transform(babelify);
bundler.transform(debowerify);
function rebundle() {
const stream = bundler.bundle();
gutil.log('Rebundle...');
return stream.on('error', handleErrors)
.pipe(source(file))
.pipe(gulpif(global.isProd, streamify(uglify())))
.pipe(streamify(rename({
basename: 'main'
const watchExample = (b, fileName) => {
const w = watchify(b).on('time', logTime(fileName));
const bundle = () => bundleExample(w, fileName);
w.on('update', bundle);
return bundle();
};
function bundler({watch, prod} = {}) {
let res = browserify(entryPoint, {standalone: exportedMethod, debug: true});
if (watch) {
res = watchify(res, {poll: true});
}
res = res
.transform({global: true}, stringify, {
appliesTo: {includeExtensions: ['.txt']}
})
.transform(babelify)
.transform(envify)
.transform({global: true}, 'browserify-shim')
.transform('browserify-versionify');
if (prod) res = res.transform(uglifyify);
return res;
}