Ejemplo n.º 1
0
    .on('end', function() {
        gulp.src('src/scripts/libraries/**/*.js')
          .pipe(gulp.dest(DEST_FOLDER + 'assets/js/libraries'));

      if(DEBUG) {
        browserify(DEST_FOLDER + 'assets/js/app.js')
          .bundle()
          .pipe(source('bundle.min.js'))
          .pipe(gulp.dest(DEST_FOLDER + 'assets/js'))
          .pipe(notify({ message: 'Script task complete' }));
      } else {
        browserify(DEST_FOLDER + 'assets/js/app.js')
          .bundle()
          .pipe(source('bundle.min.js'))
          .pipe(buffer())
          .pipe(uglify())
          .pipe(gulp.dest(DEST_FOLDER + 'assets/js'))
          .pipe(notify({ message: 'Script task complete' }));
      }
  });
function bundle() {
	return b.bundle()
		// log errors if they happen
		.on('error', gutil.log.bind(gutil, 'Browserify Error'))
		.pipe(source('browser.js'))
		// optional, remove if you don't need to buffer file contents
		.pipe(buffer())
		.pipe(babel({
			comments: false,
			"presets": ["es2015"]
		}))
		.pipe(uglify())
		// optional, remove if you dont want sourcemaps
		.pipe(sourcemaps.init({
			loadMaps: true
		})) // loads map from browserify file
		// Add transformation tasks to the pipeline here.
		.pipe(sourcemaps.write('./')) // writes .map file
		.pipe(gulp.dest('./build'));
}
Ejemplo n.º 3
0
gulp.task('minify-js', function () {

  // use `vinyl-transform` to wrap the regular ReadableStream returned by `b.bundle();` with vinyl file object
  // so that we can use it down a vinyl pipeline
  // while taking care of both streaming and buffered vinyl file objects
  var browserified = transform(function(filename) {
    // filename = './app.js' in this case
    return browserify({entries: filename, debug: true})
      .bundle();
  });

  return gulp.src(['./src/app.js']) // you can also use glob patterns here to browserify->uglify multiple files
    .pipe(browserified)
    .pipe(buffer())
    .pipe(sourcemaps.init({loadMaps: true}))
    .pipe(uglify())
    .pipe(sourcemaps.write('./'))
    .pipe(gulp.dest('./dist/'))
    .pipe(connect.reload());
});
Ejemplo n.º 4
0
gulp.task("build:application", ["jshint", "i18n"], () => {
    return browserify({
        entries: `${src}/js/app.js`,
        debug: true
    })
    .transform(babelify, {presets: ["es2015", "react"]})
    .bundle()
    .pipe(source("app.js"))
    .pipe(buffer())
    .pipe($.preprocess(PREPROCESSOR_CONTEXT))
    .pipe($.addSrc(externalJsSources))
    .pipe($.if(DEVEL, $.sourcemaps.init({loadMaps: true})))
    .pipe($.if(PRODUCTION, $.uglify()))
    .pipe($.concat("app.js"))
    .pipe($.if(DEVEL, $.sourcemaps.write(".")))
    .pipe(gulp.dest(`${dist}/js`))
    .pipe($.pako.gzip())
    .pipe(gulp.dest(`${dist}/js`))
    .pipe($.size({title: ">>> build:application"}));
});
Ejemplo n.º 5
0
 function bundle() {
     var _bundle = b.bundle().on('error', function() {
             var args = Array.prototype.slice.call(arguments)
             $.notify.onError({
                 title: 'Compile Error',
                 message: '<%= error %>'
             }).apply(this, args)
             this.emit('end')
         })
         .pipe(source('bundle.js'))
         .pipe(buffer())
         .pipe(gulp.dest(path.static))
         if (opts.isDebug) {
             _bundle = _bundle.pipe($.sourcemaps.init({
                 loadMaps: true
             })) // loads map from browserify file
             .pipe($.sourcemaps.write('./'))
         }
     return _bundle
 }
Ejemplo n.º 6
0
], function () {
  var stream = browserify('./src/jquery.clicky.js')
    .bundle()
    .pipe(source('jquery.clicky.js'))
    .pipe(buffer())
    .pipe(wrap({
      header: header
    }))
    .pipe(template(pkg))
    .pipe(gulp.dest('./bin'))
    .pipe(uglify({
      preserveComments: function (node, comment) {
        return /^\*\!/.test(comment.value);
      }
    }))
    .pipe(rename('jquery.clicky-min.js'))
    .pipe(gulp.dest('./bin'));

  return stream;
});
    var bundle = function() {
      // Log when bundling starts
      bundleLogger.start(bundleConfig.outputName);

      return bundler
        .bundle()
        // Report compile errors
        .on('error', handleErrors)
        .pipe(mold.transformSourcesRelativeTo('./'))

        // Use vinyl-source-stream to make the
        // stream gulp compatible. Specifiy the
        // desired output filename here.

        .pipe(source(bundleConfig.outputName))
        .pipe(buffer())
        // Specify the output destination
        .pipe(gulp.dest(bundleConfig.dest))
        .on('end', reportFinished);
    };
Ejemplo n.º 8
0
gulp.task('javascript', ['handlebars'], function () {
    // set up the browserify instance on a task basis
    var b = browserify({
        entries: 'src/app/index.js',
        debug: true
    });

    b.ignore('canvas');


    return b.bundle()
        .pipe(source('app.js'))
        .pipe(buffer())
        .pipe(sourcemaps.init({loadMaps: true}))
        // Add transformation tasks to the pipeline here.
        .pipe(uglify())
        .on('error', onError)
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest('./dist/js/'));
});
Ejemplo n.º 9
0
module.exports = options => (cb) => {
  if(options.development){
    return cb();
  }
  return browserify({
    insertGlobals: true,
    entries: [paths.input.files.app]
  })
    .transform(browserifyShim)
    .external(paths.input.files.vendor_js)
    // .add(build.input.files.polyfill_js)
    .bundle()
    .on('error', console.error.bind(console))
    .pipe(source('app.js'))
    // http://stackoverflow.com/questions/24992980/how-to-uglify-output-with-browserify-in-gulp
    // Convert from streaming to buffered vinyl file object for uglify
    .pipe(buffer())
    .pipe(uglify())
    .pipe(gulp.dest(paths.output.dirs.scripts));
};
Ejemplo n.º 10
0
gulp.task('diligent', function() {
    /*
    var clients = browserify({
            entries: ['./lib/framework/diligent/clients/clients.js'],
            paths: LIB_PATHS,
            debug: DEBUG
        })
        .bundle()
        .pipe(source('clients.min.js'));

    if (!DEBUG)
        clients = clients.pipe(buffer()).pipe(uglify());

    clients.pipe(gulp.dest(OUTPATH + '/lib/framework/diligent/'));
    */

    var agent_js = browserify({
        entries: ['./lib/framework/diligent/agent/js/agent.js'],
            paths: LIB_PATHS,
            debug: DEBUG
        })
        .transform(reactify)
        .bundle()
        .pipe(source('agent.min.js'));

    if (!DEBUG)
        agent_js = agent_js.pipe(buffer()).pipe(uglify());

    agent_js.pipe(gulp.dest(OUTPATH + '/lib/framework/diligent/'));

    var agent_css = gulp.src('lib/framework/diligent/agent/css/*.css')
        .pipe(concat('agent.min.css'))
        .pipe(minifycss())
        .pipe(gulp.dest(OUTPATH + '/lib/framework/diligent/'));

    return merge(
        /*clients,*/
        agent_js,
        agent_css
    );
});
Ejemplo n.º 11
0
function compile() {
  return browserify({ debug: true, standalone: 'bespoke.plugins.markdownIt' })
    .add('./lib/bespoke-markdownit.js')
    .bundle()
    .pipe(source('bespoke-markdownit.js'))
    .pipe(buffer())
    .pipe(
      header(
        [
          '/*!',
          ' * <%= name %> v<%= version %>',
          ' *',
          ' * Copyright <%= new Date().getFullYear() %>, <%= author.name %>',
          ' * This content is released under the <%= license %> license',
          ' */\n\n'
        ].join('\n'),
        pkg
      )
    )
    .pipe(dest('dist'))
    .pipe(rename('bespoke-markdownit.min.js'))
    .pipe(terser({
      ecma: 8,
      compress: {
        unsafe: true,
        arguments: true,
        'drop_console': true
      }
    }))
    .pipe(
      header(
        [
          '/*! <%= name %> v<%= version %> ',
          '© <%= new Date().getFullYear() %> <%= author.name %>, ',
          '<%= license %> License */\n'
        ].join(''),
        pkg
      )
    )
    .pipe(dest('dist'));
}
Ejemplo n.º 12
0
gulp.task("vendor", ["bower"], function () {
    "use strict";
    return browserify()
        .require("vow")
        .bundle()
        .on("error", handleErrors)
        .pipe(source("vendor.js"))

        // Convert stream
        .pipe(buffer())
        .pipe(gulp.dest("./dist/"))

        // Rename the destination file
        .pipe(rename("vendor.min.js"))

        // Minify the bundled JavaScript
        .pipe(uglify())

        // Output to the build directory
        .pipe(gulp.dest("./dist"));
});
Ejemplo n.º 13
0
gulp.task("styles", () => {
    return gulp.src([
        `${src}/scss/screen.scss`
    ])
    .pipe($.compass({
        css: `${dist}/css`,
        sass: `${src}/scss`,
        image: `${dist}/images`
    }))
    .pipe(buffer())
    .pipe($.autoprefixer())
    .pipe($.importCss())
    .pipe($.concat("app.css"))
    .pipe($.cssnano({
        reduceIdents: false,
        mergeIdents: false
    }))
    .pipe(gulp.dest(`${dist}/css`))
    .pipe($.size({title: ">>> styles"}))
    .pipe(reload({stream: true}));
});
Ejemplo n.º 14
0
gulp.task('sprite', () => {
    // Generate our spritesheet
    var spriteData = gulp.src(path.s_simg+'*.png').pipe(spritesmith({
        imgName: 'sprite.png',
        cssName: 'sprite.css'
    }));

    // Pipe image stream through image optimizer and onto disk
    var imgStream = spriteData.img
    // DEV: We must buffer our stream into a Buffer for `imagemin`
    .pipe(bf())
    .pipe(imagemin())           //压缩合并的图片
    .pipe(gulp.dest(path.d_img));

    // Pipe CSS stream through CSS optimizer and onto disk
    var cssStream = spriteData.css
    .pipe(gulp.dest(path.d_css));

    // Return a merged stream to handle both `end` events
    return merge(imgStream, cssStream);
});
Ejemplo n.º 15
0
gulp.task('js', function() {
  var b = browserify({
    entries: 'client/main.js',
    debug: true,
    cache: {},
    packageCache: {},
    transform: [debowerify, babelify]
  });

  return b.bundle()
    .on('error', function(err) {
      $.util.log(err.message);
      browserSync.notify('Browerify Error!')
      this.emit('end')
    })
    .pipe(source('bundle.js'))
    .pipe(buffer())
    .pipe($.sourcemaps.init({loadMaps: true}))
    .pipe($.sourcemaps.write('./'))
    .pipe(gulp.dest('.tmp/scripts'));
});
Ejemplo n.º 16
0
    var bundle = function() {

      return bundler
        .bundle()
        // Report compile errors
        .on('error', notify.onError({
          title: "JS Compile Error",
          message: "<%= error.message %>"
        }))
        // Use vinyl-source-stream to make the
        // stream gulp compatible. Specify the
        // desired output filename here.
        .pipe(source(bundleConfig.outputName))
        .pipe(buffer())
          .pipe(sourcemaps.init()) // loads map from browserify file
          .pipe(sourcemaps.write('./')) // writes .map file
        // Specify the output destination
        .pipe(gulp.dest(bundleConfig.dest))
        .on('end', reportFinished)
        .pipe(browserSync.reload({stream:true}));
    };
Ejemplo n.º 17
0
gulp.task('js', function() {
    var stream = watchify(browserify({
        entries: ['./src/js/main.jsx'],
        transform: [babelify],
        debug: true,
        extensions: ['.jsx'],
        fullPaths: false
    }));

    vendors.forEach(function (vendor) {
        stream.external(vendor);
    });

    return stream.bundle()
        .pipe(source('all.js'))
        .pipe(buffer())
        .pipe(sourcemaps.init({ loadMaps: true }))
        .pipe(uglify())
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest('dist/js'));
});
Ejemplo n.º 18
0
gulp.task("build:installer", ["build:application"], () => {
    return browserify({
        entries: `${src}/js/app-installer.js`,
        debug: true
    })
    .transform(babelify, {presets: ["es2015", "react"]})
    .bundle()
    .pipe(source("app-installer.js"))
    .pipe(buffer())
    .pipe($.if(DEVEL, $.sourcemaps.init({loadMaps: true})))
    .pipe($.if(PRODUCTION, $.uglify()))
    .pipe($.concat("app-installer.js"))
    .pipe($.preprocess({context: {
        COMPRESSED_SIZE: fs.statSync(`${dist}/js/app.js.gz`).size,
        APP_SIZE: fs.statSync(`${dist}/js/app.js`).size,
        MD5: crypto.createHash('md5').update(fs.readFileSync(`${dist}/js/app.js`)).digest("hex")
    }}))
    .pipe($.if(DEVEL, $.sourcemaps.write(".")))
    .pipe(gulp.dest(`${dist}/js`))
    .pipe($.size({title: ">>> build:installer"}));
});
Ejemplo n.º 19
0
function doBuild(shouldMinify) {
    var build = browserify('./javascripts/main.js', {
            debug: !shouldMinify,
            standalone: 'TorFlow'
        })
        .bundle()
        .on( 'error', function( e ) {
            console.log( e );
            this.emit('end');
        })
        .pipe( source( 'torflow.js' ) );
    if (shouldMinify) {
       build = build
           .pipe(buffer())
           .pipe(uglify({
               mangle : true
           }));
    }
    build.pipe( gulp.dest( config.dist ) );
    return build;
}
Ejemplo n.º 20
0
function bundle() {
    //This will replace /* @echo __REST_URL__ */ with real value
    //and replace __DEBUG__ with real value
    b.transform(preprocessify({
        '__REST_URL__': getRestUrl(),
        '__DEBUG__': isDebug()
    }));

    return b.bundle()
        .on('error', plugins.util.log.bind(plugins.util, 'Browserify Error'))
        .pipe(source('bundle.js'))

        //minify with source map file
        .pipe(buffer())
        //.pipe(plugins.sourcemaps.init({loadMaps: true}))
        .pipe(plugins.if(!isDebug(), plugins.uglify()))
        // Add transformation tasks to the pipeline here.
        //.pipe(plugins.sourcemaps.write('./'))

        .pipe(gulp.dest(distDir));
}
Ejemplo n.º 21
0
gulp.task("bundle", function() {
  
    var libraryName = "myapp";
    var mainTsFilePath = "src/app.js";
    var outputFolder   = "dist/";
    var outputFileName = libraryName + ".min.js";

    var bundler = browserify({
        debug: true,
        standalone : libraryName
    });
    
    return bundler.add(mainTsFilePath)
        .bundle()
        .pipe(source(outputFileName))
        .pipe(buffer())
        .pipe(sourcemaps.init({ loadMaps: true }))
        .pipe(uglify())
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest(outputFolder));
});
Ejemplo n.º 22
0
    it.skip("go",function(done){

        let b = browserify(["test/resources/entry-alias.js"])
            .plugin(self,{
                alias:{
                    vue:{global:"Vue"}
                    ,module1:"./test/resources/alias/module1"
                    ,module2:"./test/resources/alias/module2"
                    ,module3:"./test/resources/alias/module3"
                }
            })

        return b.bundle()/*.on("end",_=>console.log("end"))*/
            .pipe(source("app.js"))
            .pipe(buffer())
            .pipe(through.obj((file ,enc ,next)=>{
                console.log(file.contents.toString())
                return next(null ,file)
            },()=>done()))

    })
Ejemplo n.º 23
0
 function rebundle() {
   if (w) {
     writeConfig(gutil.log);
   }
   lintJSTask(false, false)();
   return bundler.bundle()
     .on('error', (err) => { gutil.log(err); this.emit('end'); })
     .on('end', () => {
       if(w) {
         new run.Command('mvn war:exploded').exec('', () => {
           gutil.log('Bundle process finished.');
           gutil.beep();
         });
       }
     })
     .pipe(source(BUNDLE_JS_NAME))
     .pipe(buffer())
     .pipe(sourcemaps.init({ loadMaps: true }))
     .pipe(sourcemaps.write('./'))
     .pipe(gulp.dest(DIST_DIR));
 }
Ejemplo n.º 24
0
gulp.task('browserify', function () {
    var b = browserify({
        entries: './source/main.js',
        debug: true
    });

    return b.bundle()
        .pipe(source('bundle.js'))
        .pipe(buffer())
        .pipe(sourcemaps.init({
            loadMaps: true,
            debug: true
        }))
        // Add transformation tasks to the pipeline here.
//         .pipe(uglify())
//         .on('error', gutil.log)
        .pipe(sourcemaps.write('./', {
            debug: true
        }))
        .pipe(gulp.dest('./dist/js'));
});
Ejemplo n.º 25
0
gulp.task('bundle-dev', function () {
  return browserify({
    entries: ['public/src/js/app.js'],
    // debug: true will bundle together a "source map" so we will still be able to view the individual source files in the browser devtools
    debug: true
  })
  .bundle()

  // if there is an error with our javascript, this will keep gulp from breaking
  .on('error', function(error) {
    console.log(error.toString());
    this.emit('end');
  })

  // this names the bundled file
  .pipe(source('bundle.js'))
  .pipe(buffer())

  // this places the file in our public/js/ directory
  .pipe(gulp.dest('public/dist/js/'));
});
Ejemplo n.º 26
0
gulp.task('build:scripts', function() {
    return browserify(filePaths.src.scripts.entry, {
            paths: ['./node_modules', './src'],
            debug: env === 'development'
        })
        .transform(babelify, { presets: ['es2015', 'react']})
        .bundle()
        .on('error', function(err) {
            gutil.log(gutil.colors.red(err));
        })
        .pipe(source(filePaths.src.scripts.bundled))
        .pipe(buffer())
        .pipe(gulpif(env === 'development', sourcemaps.init({
            loadMaps: true
        })))
        .pipe(gulpif(env === 'production', uglify({
            mangle: false
        })))
        .pipe(gulpif(env === 'development', sourcemaps.write('./')))
        .pipe(gulp.dest(filePaths.dest));
});
Ejemplo n.º 27
0
    gulp.task('build-js', function () {
	  var magic = browserify({
	    entries: input.javascript,
	    debug: true
	  });
	  magic.transform(babelify.configure({
	  	presets: ["es2015"]
	  }));
	  magic.bundle()
	  	.pipe(plumber({ errorHandler: onError }))
	    .pipe(source('app.js'))
	    .pipe(buffer())
	    .pipe(sourcemaps.init({loadMaps: true}))
	    	.pipe(jshint())
	    	.pipe(jshint.reporter(stylish))
	        .pipe(uglify())
	        .on('error', gutil.log)
	    .pipe(sourcemaps.write(output.maps))
	    .pipe(gulp.dest(output.javascript))
	    .pipe(notify('ES6 compiled to JS, Linted, Bundled, and Minified'));
	});
Ejemplo n.º 28
0
  const bundles = addons.map((addon) => {
    const addonOptions = {
      basedir: `${buildDir}/addons/${addon}`,
      debug: true,
      entries: [`${outDir}/addons/${addon}/${addon}.js`],
      standalone: addon,
      cache: {},
      packageCache: {}
    };

    const addonBundle = browserify(addonOptions)
      .external(path.join(outDir, 'Terminal.js'))
      .bundle()
      .pipe(source(`./addons/${addon}/${addon}.js`))
      .pipe(buffer())
      .pipe(sourcemaps.init({loadMaps: true, sourceRoot: ''}))
      .pipe(sourcemaps.write('./'))
      .pipe(gulp.dest(buildDir));

    return addonBundle;
  });
Ejemplo n.º 29
0
 function bundle () {
   gutil.log('Bundling ' + gutil.colors.magenta(config.output) + '...');
   var start = process.hrtime();
   return bundler
     .bundle()
     .pipe(source(config.output))
     .pipe(buffer())
     .pipe(gulpif(env.isDev(), rename({suffix: '.min'})))
     .pipe(gulpif(env.isDev(), sourcemaps.init({loadMaps: true})))
     .pipe(ngAnnotate())
     .pipe(uglify())
     .pipe(gulpif(env.isDev(), sourcemaps.write('./')))
     .pipe(gulpif(env.isProd(), rev()))
     .pipe(gulpif(env.isProd(), rename({suffix: '.min'})))
     .pipe(gulp.dest(config.dest))
     .on('end', function () {
       var end = process.hrtime(start);
       var prettyTime = prettyHrtime(end);
       gutil.log('Bundled ' + gutil.colors.magenta(config.output) + ' after ' + gutil.colors.magenta(prettyTime));
     });
 }
Ejemplo n.º 30
0
gulp.task('build:javascript', function () {
  return rollup({
    input: config.bundle.entry,
    format: 'umd',
    name: '<#=name#>',
    cache: rollupCache,
    plugins: [
      vue({
        css: false
      }),
      buble()
    ]
  })
    .on('bundle', function (bundle) {
      rollupCache = bundle
    })
    .pipe(source(config.bundle.destFileName))
    .pipe(buffer())
    .pipe(gulp.dest(config.bundle.dest))
    .pipe(connect.reload())
})