gulp-replace

How to use a Capture Group with gulp-replace?

最后都变了- 提交于 2020-01-04 05:05:07
问题 gulp-replace 0.5.4 Current via gulp and rev: <link rel="stylesheet" href="assets/styles/app-3c224ff086.css"> Goal : <link rel="stylesheet" href="assets/styles/app-3c224ff086.css" media="screen"> Result : <link rel="stylesheet" href="$1" media="screen"> Initial test was: https://regex101.com/r/miM7TN/1 . I might have linked the test with a capture group of $0, but in my project I am using capture group 1. In my gulp task the following is added: var regex = /\"assets\/styles\/app-+.*\"/; var

What's the most efficient way to read, rebuild, and replace a block of content in a file using Gulp?

主宰稳场 提交于 2020-01-04 00:42:12
问题 I'm creating a system that can read through any file (php, jsp, html, etc), locate block tags, and do a replacement based on the information in the block tag. Code I would write into my file: <!-- build:<name> --> { "testObject": { "name": "jonathan", "number": 3, "male": true } } <!-- endBuild --> Desired replacement: <h1>Jonathan</h1> <p>is a male and is positioned at #3.</p> As you may notice, I've used components of gulp-html-replace. I've researched gulp-data and know how to use gulp.src

How to rewrite a file before publish based on build configuration?

时光毁灭记忆、已成空白 提交于 2019-12-24 00:43:44
问题 I have a new asp.net V5 application that is really just a static angular site and I'm trying to do the equivalent of web.config transforms. My app.js file has a constant defined that is the serviceUrl which points to the url of our api (not in the same site) I've used gulp-replace and created tasks for each of our build targets that successfully replace the single string that needs to be replaced. The problem I'm having is that I need to be able to change that service url based on the build

How can I use gulp to replace a string in a file?

余生长醉 提交于 2019-12-18 14:04:47
问题 I am using gulp to uglify and make ready my javascript files for production. What I have is this code: var concat = require('gulp-concat'); var del = require('del'); var gulp = require('gulp'); var gzip = require('gulp-gzip'); var less = require('gulp-less'); var minifyCSS = require('gulp-minify-css'); var uglify = require('gulp-uglify'); var js = { src: [ // more files here 'temp/js/app/appConfig.js', 'temp/js/app/appConstant.js', // more files here ], gulp.task('scripts', ['clean-js'],

How can I use gulp to replace a string in a file?

本秂侑毒 提交于 2019-11-30 11:15:49
I am using gulp to uglify and make ready my javascript files for production. What I have is this code: var concat = require('gulp-concat'); var del = require('del'); var gulp = require('gulp'); var gzip = require('gulp-gzip'); var less = require('gulp-less'); var minifyCSS = require('gulp-minify-css'); var uglify = require('gulp-uglify'); var js = { src: [ // more files here 'temp/js/app/appConfig.js', 'temp/js/app/appConstant.js', // more files here ], gulp.task('scripts', ['clean-js'], function () { return gulp.src(js.src).pipe(uglify()) .pipe(concat('js.min.js')) .pipe(gulp.dest('content