How to use the gulp-replace function in gulp-replace

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 CALIL / unitrad-ui / gulpfile.babel.js View on Github external
{
      paths: ['./src/js/'],
      debug: process.env.NODE_ENV !== 'production'
    }
  ).transform(babelify)
    .plugin(licensify)
    .plugin('bundle-collapser/plugin')
    .bundle()
    .pipe(source('app.js'))
    .pipe(header(confjs))
    .pipe(buffer())
    .pipe(process.env.NODE_ENV !== 'production' ? sourcemaps.init({loadMaps: true}) : through.obj())
    .pipe(process.env.NODE_ENV === 'production' ? uglify({output: {comments: /Modules in this bundle/mi}}) : through.obj())
    .pipe(process.env.NODE_ENV !== 'production' ? sourcemaps.write('./map') : through.obj())
    .pipe((page.replace_js && page.replace_js.length > 0) ? replace(page.replace_js[0].match, page.replace_js[0].replacement) : through.obj())
    .pipe((page.replace_js && page.replace_js.length > 1) ? replace(page.replace_js[1].match, page.replace_js[1].replacement) : through.obj())
    .pipe((page.replace_js && page.replace_js.length > 2) ? replace(page.replace_js[2].match, page.replace_js[2].replacement) : through.obj())
    .pipe(gulp.dest(destDir));
});
github vmarcosp / minimalist-profile / gulpfile.babel.js View on Github external
gulp.task('build:replace-fa', ['build:fa'], () =>
  gulp.src(`${ASSETS_PATH}/css/all.min.css`)
    .pipe(gulpReplace('../../node_modules/font-awesome', '..'))
    .pipe(gulp.dest(`${ASSETS_PATH}/css`))
)
github bcvsolutions / CzechIdMng / Realization / frontend / czechidm-app / gulpfile.babel.js View on Github external
gulp.task('createRouteAssembler', () => gulp.src(paths.srcRouteAssembler)
  .pipe(replace(compileMark, routesAssemblerContent))
  .pipe(gulp.dest(paths.distModule)));
github SanderRonde / CustomRightClickMenu / gulpfile.ts View on Github external
static copyMonacoBeautiful() {
						return gulp
							.src([
								'**/**',
								'!vs/basic-languages/src/**',
								'vs/basic-languages/src/css.js',
								'vs/basic-languages/src/less.js'
							], {
									base: 'node_modules/monaco-editor/min',
									cwd: 'node_modules/monaco-editor/min'
								})
							.pipe(replace(/node = node\.parentNode/g,
								'node = node.parentNode || node.host'))
							.pipe(replace(/document\.body/g,
								'MonacoEditorHookManager.getLocalBodyShadowRoot'))
							.pipe(replace(/document\.caretRangeFromPoint/g,
								'MonacoEditorHookManager.caretRangeFromPoint(arguments[0])'))
							.pipe(replace(/this.target(\s)?=(\s)?e.target/g,
								'this.target = e.path ? e.path[0] : e.target'))
							.pipe(beautify())
							.pipe(gulp.dest('app/elements/options/editpages/monaco-editor/src/min/'));
					};

gulp-replace

A string replace plugin for gulp

MIT
Latest version published 1 year ago

Package Health Score

59 / 100
Full package analysis