Any Gulp experts in the house?



  • I managed to get browserify working correctly, mostly because the TypeScript help pages had an example that was almost exactly what I needed.

    var gulp = require("gulp");
    var browserify = require("browserify");
    var source = require('vinyl-source-stream');
    var tsify = require("tsify");
    
    gulp.task("create-extensions", function ()
    {
    });
    
    gulp.task("default", ["create-extensions"], function ()
    {
    	return browserify({
    		basedir: '.',
    		debug: true,
    		entries: ['source/loader.js'],
    		cache: {},
    		packageCache: {}
    	})
    	.plugin(tsify)
    	.bundle()
    	.pipe(source('bundle.js'))
    	.pipe(gulp.dest("build"));
    });
    

    (And seriously, who in a billion years would be able to determine something called "vinyl-source-stream" would be required?)

    Now I'm stuck on a far easier task:

    • copy files in ./static to ./build/chrome-extension
    • copy file ./manifests/manifest-chrome to ./build/chrome-extension/manifest.json
    • copy files in ./static to ./build/edge-extension
    • copy file ./manifests/manifest-edge to ./build/edge-extension

    So. Just a few file copies, and I can't figure out how to tell Gulp to do it. Any help out there?



  • @blakeyrat I AM KING OF GULP KINGDOM

    var gulp = require("gulp");
    var rename = require("gulp-rename");
    var browserify = require("browserify");
    var source = require("vinyl-source-stream");
    var tsify = require("tsify");
    
    gulp.task("default", ["compile-source"], function ()
    {
    	gulp.src([
    		"static/*",
    		"lib/*"
    	])
    	.pipe(gulp.dest("build/chrome-extension"));
    
    	gulp.src([
    		'manifests/manifest-chrome.json'
    	])
    	.pipe(rename("manifest.json"))
    	.pipe(gulp.dest("build/chrome-extension"));
    
    	gulp.src([
    		"build/bundle.js"
    	])
    	.pipe(gulp.dest("build/chrome-extension"));
    
    	gulp.src([
    		"static/*",
    		"lib/*"
    	])
    	.pipe(gulp.dest('build/edge-extension'));
    
    	gulp.src([
    		'manifests/manifest-edge.json'
    	])
    	.pipe(rename("manifest.json"))
    	.pipe(gulp.dest('build/edge-extension'));
    
    	gulp.src([
    		"build/bundle.js"
    	])
    	.pipe(gulp.dest("build/edge-extension"));
    });
    
    gulp.task("compile-source", function ()
    {
    	return browserify({
    		basedir: ".",
    		debug: true,
    		entries: ["source/loader.js"],
    		cache: {},
    		packageCache: {}
    	})
    	.plugin(tsify)
    	.bundle()
    	.pipe(source("bundle.js"))
    	.pipe(gulp.dest("build"));
    });
    

    That was way harder than it needed to be. In particular, that renaming a file requires installing a different NPM package, which is ridonkulous.


  • Impossible Mission - B

    @blakeyrat said in Any Gulp experts in the house?:

    NPM ... is ridonkulous

    I agree fully 🚎


Log in to reply