Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fs.mkdirp(unpackedDir, err => {
if (err && err.code !== 'EEXIST') {
console.log(err);
throw err;
}
let unpackedFile = path.join(__dirname, 'unpacked.js');
let b = browserify(unpackedFile).bundle();
b.on('error', console.error);
let unpackedBundleFile = path.join(unpackedDir, 'unpacked-bundle.js');
const bundleFileStream = fs.createWriteStream(unpackedBundleFile);
bundleFileStream.on('finish', () => {
console.log('Wrote bundled JS into ' + unpackedBundleFile);
});
bundleFileStream.on('pipe', () => {
console.log('Writing bundled JS...');
});
bundleFileStream.on('error', console.error);
b.pipe(bundleFileStream);
// bundleFileStream.end(); // do not do this prematurely!
});
}
gulp.task('script', () => {
const isProduction = (process.env.NODE_ENV === 'production');
const bundleConfig = {
name: 'inkjet',
entries: [`./src/index.js`], // require.resolve('babel-polyfill'),
dest: './dist',
outputName: `inkjet${isProduction ? '.min' : ''}.js`,
isUglify: isProduction,
};
let bundler = browserify({
entries: bundleConfig.entries,
insertGlobals: false,
detectGlobals: true,
standalone: bundleConfig.name,
debug: false
});
let bundle = () => {
return bundler
.bundle()
.on('error', handleErrors)
.pipe(source(bundleConfig.outputName))
.pipe(header(banner, { pkg: pkg }))
.pipe(gulpIf(bundleConfig.isUglify, uglify()))
.pipe(gulp.dest(bundleConfig.dest))
};
import gulp from 'gulp';
import gutil from 'gulp-util';
import uglify from 'gulp-uglify';
import browserify from 'browserify';
import watchify from 'watchify';
import source from 'vinyl-source-stream';
import buffer from 'vinyl-buffer';
import { join } from 'path';
import browserSync from './connect';
import { libraries, server, browserify as blabla } from '../config';
const { dest } = server
const config = Object.assign({}, watchify.args, blabla);
const bundler = watchify(browserify(config));
const buildBundler = browserify(config);
function bundle() {
return bundler.bundle()
.on('error', err => gutil.log.call(this, err))
.pipe(source('bundle.min.js'))
.pipe(buffer())
.pipe(gulp.dest(dest))
.pipe(browserSync.stream());
}
function buildBundle() {
return buildBundler.bundle()
.on('error', err => gutil.log.call(this, err))
.pipe(source('bundle.min.js'))
.pipe(buffer())
const tasks = ['js/autocomplete.js', 'js/autocomplete-ractive.js'].map(entry => {
return rebundle(browserify(assign(browserifyArgs, { entries: [entry] })), entry);
});
var tasks = files.map(function(entry) {
return browserify({ entries: [entry] })
.transform(babelify)
.bundle()
.pipe(source(entry))
.pipe(gulp.dest(paths.dist));
});
es.merge(tasks).on('end', done);
gulp.task('browserify', () => {
return browserify('./src/index.js', {standalone: 'Semantify'})
.transform('babelify', {presets: ['es2015', 'react', 'stage-0']})
.transform(globalShim.configure({
'react': 'React'
}))
.bundle()
.pipe(source('react-semantify.js'))
.pipe(gulp.dest(build_path))
.pipe(buffer())
.pipe(uglify())
.pipe(grename('react-semantify.min.js'))
.pipe(gulp.dest(build_path));
});
_getFile() {
let bundle = browserify();
bundle.add(this.assetSource);
if (this.plugins) {
if (!_.isUndefined(this.plugins.babelify)) {
bundle = bundle.transform(
babelify.configure(this.plugins.babelify || {})
);
}
if (!_.isUndefined(this.plugins.uglifyify)) {
bundle = bundle.transform(
uglifyify
);
}
}
return new Promise((resolve, reject) => {
const srces = {
css: 'src/plugin.scss',
js: 'src/plugin.js',
tests: glob.sync('test/**/*.test.js')
};
const dests = {
css: nameify('dist/%s.css'),
js: nameify('dist/%s.js'),
tests: 'test/dist/bundle.js'
};
const bundlers = {
js: browserify({
debug: true,
entries: [srces.js],
standalone: nameify('%s'),
transform: [
'babelify',
['browserify-shim', {global: true}],
'browserify-versionify'
]
}),
tests: browserify({
debug: true,
entries: srces.tests,
transform: [
'babelify',
['browserify-shim', {global: true}],
gulp.task('browserify', () => {
return browserify('./src/index.js')
.transform('babelify', {presets: ['es2015', 'react', 'stage-3']})
.transform(globalShim.configure({
'react': 'React'
}))
.bundle()
.pipe(source('react-github-fork-ribbon.js'))
.pipe(gulp.dest(build_path))
.pipe(buffer())
.pipe(uglify())
.pipe(grename('react-github-fork-ribbon.min.js'))
.pipe(gulp.dest(build_path));
});