How to use gulp-replace - 10 common examples

To help you get started, we’ve selected a few gulp-replace examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gchudnov / jpeg-asm / scripts / gulp / tasks / browserify.js View on Github external
let bundle = () => {
      bundleLogger.start(bundleConfig.outputName);
      return bundler
        .bundle()
        .on('error', handleErrors)
        .pipe(source(bundleConfig.outputName))
        .pipe(buffer())
        .pipe(replace(/&&\s*!ENVIRONMENT_IS_WEB\s*&&\s*!ENVIRONMENT_IS_WORKER/, '')) // PATCH: cannot detect NODE in a browser.
        .pipe(replace(/!!process\.platform\.match\(\/\^win\/\)/, 'false'))           // PATCH: process.platform is undefined
        .pipe(replace(/process\[['"]stderr['"]\]\.write/, 'console.error'))          // PATCH: process.stderr is undefined
        .pipe(replace(/process\[['"]stdout['"]\]\.write/, 'console.log'))            // PATCH: process.stdout is undefined
        .pipe(gulpIf(IS_PRODUCTION, uglify())) // { mangle: false }
        .pipe(gulp.dest(bundleConfig.dest))
        .on('end', handleEnd);
    };
github prixe / lindo / gulpfile.babel.js View on Github external
downloadBinary('https://proxyconnection.touch.dofus.com/build/script.js', './game/build/script.js', function () {
                gulp.src(['./game/build/script.js'])
                    .pipe(prettify({
                        "break_chained_methods": true,
                    }))
                    .pipe(replace("cdvfile://localhost/persistent/data/assets", "assets"))
                    .pipe(replace("window.Config.analytics", "null"))
                    .pipe(replace(/(overrideConsole.=.function\(\) {)([^])*(},._.logUncaughtExceptions)/g, '$1$3'))
                    .pipe(replace(/(logUncaughtExceptions.=.function\(.*\).{)([^])*(},.*\.exports.*=.*_\n},.*function\(e,.*t,.*i\))/g, '$1$3'))
                    .pipe(replace(/this.send\(.*, d\("login"\)\)/g, 'var _scm_ = d("login"); for (var i in window._){ _scm_[i] = window._[i]}; this.send("connecting", _scm_);'))
                    .pipe(replace(/(this\.send\(.*,.d\({\n.*\n.*\n.*\n.*\n.*)(}\),.*\("serverDisconnecting")/g, 'var _scm_ = d({address: a,port: r,id: e}); for (var i in window._) {_scm_[i] = window._[i]};this.send("connecting", _scm_);$2'))
                    .pipe(replace(/window\.buildVersion.*=.*"\d*\.\d*\.\d*",/g, ""))
                    // .pipe(replace(/(var.*=.*\.touches\s\|\|.*\[\],)/g, 'if (e.type === "mousedown" || e.type === "mouseup") {return o.x = e.clientX, o.y = e.clientY, { x: o.x, y: o.y, touchCount: "mouseup" === e.type ? 0 : 1, touches: [{x: o.x, y: o.y }] } }\n$1'))
                    // .pipe(replace(/(\"ontouchstart\" in window)/g, "false && $1"))
                    .pipe(replace(/(var\s*[a-z]*\s*=\s*this,\n*\s*[a-z]*\s=\s*window\.dofus\.connectionManager;\n\s*i.on\("ServersListMessage",)/g, "window.d = this; \n $1"))
                    .pipe(replace(/([a-z]\([a-z],\s*[a-z]\),\s*[a-z]\.exports\s*=\s*n,\s*n\.prototype\._addFightModeToolTip\s*=\s*function\([a-z],\s*[a-z],\s*[a-z]\)\s*{)/g, "window.CharacterDisplay = c;\n\t$1"))
                    .pipe(replace(/(, window\.fetch\(.+\/logger)/g, "; top.console.log(n); return null $1"))
                    .pipe(gulp.dest('./game'))
                    .on('end', callback);
            });
github gchudnov / jpeg-asm / scripts / gulp / tasks / browserify.js View on Github external
let bundle = () => {
      bundleLogger.start(bundleConfig.outputName);
      return bundler
        .bundle()
        .on('error', handleErrors)
        .pipe(source(bundleConfig.outputName))
        .pipe(buffer())
        .pipe(replace(/&&\s*!ENVIRONMENT_IS_WEB\s*&&\s*!ENVIRONMENT_IS_WORKER/, '')) // PATCH: cannot detect NODE in a browser.
        .pipe(replace(/!!process\.platform\.match\(\/\^win\/\)/, 'false'))           // PATCH: process.platform is undefined
        .pipe(replace(/process\[['"]stderr['"]\]\.write/, 'console.error'))          // PATCH: process.stderr is undefined
        .pipe(replace(/process\[['"]stdout['"]\]\.write/, 'console.log'))            // PATCH: process.stdout is undefined
        .pipe(gulpIf(IS_PRODUCTION, uglify())) // { mangle: false }
        .pipe(gulp.dest(bundleConfig.dest))
        .on('end', handleEnd);
    };
github cs-education / sysbuild / webapp / gulp-tasks / build-styles.js View on Github external
gulp.task('css:dist', () => {
    return compiledCssStream({
            sassImportPathModifier: (url, prev) => {
                // inline CSS imports
                if (url.slice(-4) === '.css') {
                    url = url.slice(0, -4);
                }
                return url;
            }
        })
        // rewrite relative links to Bootstrap fonts
        .pipe(replace(/url\((['"])?bower_modules\/bootstrap-sass\/assets\/fonts\/bootstrap\//g, 'url($1fonts/'))
        // jquery-notific8 font URLs are already as desired
        .pipe(minifyCss({ compatibility: '*' }))
        .pipe(gulp.dest('./dist/'));
});
github dnote / browser-extension / gulpfile.babel.js View on Github external
let tasks = files.map(file => {
    return (
      browserify({
        entries: "./src/scripts/" + file,
        debug: true
      })
        .transform("babelify", {
          presets: ["es2015", "es2017", "stage-0", "react"]
        })
        .bundle()
        .pipe(source(file))
        // inject variables
        .pipe(
          replace(
            "__API_ENDPOINT__",
            isProduction ? "https://api.dnote.io" : "http://127.0.0.1:5000"
          )
        )
        .pipe(replace("__VERSION__", manifest.version))
        .pipe(gulp.dest(`dist/${target}/scripts`))
    );
  });
github dwst / dwst / gulpfile.babel.js View on Github external
export function buildHtml() {
  // We bundle javascript with webpack for production builds
  // So we should be fine without the module system
  return gulp.src(sourcePaths.html)
    .pipe(replace('
github eBay / jsonpipe / gulpfile.js View on Github external
.on('finish', function() {
            // generate coverage.json after finish
            gulp.src(coverageJSON)
                .pipe(istanbulReport({reporters: ['lcov']}));

            // Revert the html file
            gulp.src(htmlFile)
                .pipe(replace.apply(null, replaceStrs.reverse()))
                .pipe(gulp.dest('test'));
        });
});
github eBay / jsonpipe / gulpfile.js View on Github external
gulp.task('test-cov', ['instrument'], function() {
    var htmlFile = 'test/jsonpipe.html',
        replaceStrs = ['../jsonpipe.js', '../lib-cov/jsonpipe.js'],
        coverageJSON = 'coverage/coverage.json';

    return gulp.src(htmlFile)
        .pipe(replace.apply(null, replaceStrs))
        .pipe(gulp.dest('test')) // Override the same file
        .pipe(mochaPhantomJS({
            reporter: 'spec',
            phantomjs: {
                hooks: 'mocha-phantomjs-istanbul',
                coverageFile: coverageJSON
            }
        }))
        .on('finish', function() {
            // generate coverage.json after finish
            gulp.src(coverageJSON)
                .pipe(istanbulReport({reporters: ['lcov']}));

            // Revert the html file
            gulp.src(htmlFile)
                .pipe(replace.apply(null, replaceStrs.reverse()))
github CreaturePhil / Showdown-Boilerplate / gulpfile.js View on Github external
function transformLet() {
	// Replacing `var` with `let` is sort of a hack that stops jsHint from
	// complaining that I'm using `var` like `let` should be used, but
	// without having to deal with iffy `let` support.

	return lazypipe()
		.pipe(replace.bind(null, /\bvar\b/g, 'let'))();
}
github nguymin4 / react-videocall / client / tasks / gulpProd.js View on Github external
gulp.task("html", function () {
		var src = gulp.src(input.html.target);

		// Add meta data
		for (var keyword in metaData) {
			var meta = metaData[keyword];
			if (typeof meta !== "string")
				meta = env.isProduction ? meta["build"] : meta["dev"];
			meta = (meta || "").replace(/[\n\t]/g, "");
			src = src.pipe(replace.call(this, "${" + keyword + "}", meta));
		}

		return src.pipe(gulp.dest(output.html));
	});

gulp-replace

A string replace plugin for gulp

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis