mikehazell / gulp-inject-string Goto Github PK
View Code? Open in Web Editor NEWInject snippets in build
License: MIT License
Inject snippets in build
License: MIT License
It would be very recommended to rewrite doc. samples replacing \n
with \r\n
. It is a good practice, in addition to avoiding unexpected and bizarre errors like this one.
Hi! I'm using inject.replace
to turn my webpack output into a single file. It works for the most part, except for the files that I've noticed have this string $&
which is either generated by webpack or the package I'm using. This results in the search term being injected into the inject.replace
result. Since that's what $&
does in regex.
Is there a way to prevent this behavior? Thanks!
gulp-util
has been deprecated recently. Continuing to use this dependency may prevent the use of your library with the latest release of Gulp 4 so it is important to replace gulp-util
.
The README.md lists alternatives for all the components so a simple replacement should be enough.
Your package is popular but still relying on gulp-util
, it would be good to publish a fixed version to npm as soon as possible.
See:
Hi there,
how about you modify the replace
method a little so it would handle proper regular expressions.
Maybe have a look at https://github.com/lazd/gulp-replace/blob/master/index.js#L22
Thanks a lot for this package!
Chris
Update event-stream dependency to [email protected] per
It's can't process directory.
Throw an error.
I read the source code.
// assume str is a string for now
Please fix
return es.map(function (file, cb) {
if (!file.contents) {
return cb(null)
}
try {
file.contents = new Buffer(injectMethod(String(file.contents)));
} catch (err) {
return cb(new PluginError('gulp-inject-string', err));
}
cb(null, file);
});
It would be nice if we could add a line before and after a regex match. Rather than a complete string
Replace is not working with a block comment in scss, e.g. /*@replaceme*/
. Regular comments are working. Example:
gulpfile.js:
return gulp
.src('./styles.scss')
.pipe(inject.replace('/*@replaceme*/', '123')) // No effect
.pipe(inject.replace('//@replaceme', '345')) // Working
.pipe(gulp.dest('./'))
;
styles.scss:
'/*@replaceme*/ //@replaceme
Hi, I need to make something more difficult than just string replace. And I think about implementing custom method that will give us ability to make any manipulations with strings on javascript.
For example. I've faced with problem when on my gulp environment I've needed parse regex occurrence and return different strings. Here is my working code:
.pipe($.injectString.custom(function (str) { return str.replace(new RegExp('(z-var\\s*:\\s*)(\\w*)(.*;)', 'g'), function (match, g1, g2, g3) { return '{' + g2 + '}'; }); })
This function find and replace z-var: varName;
to {varName}
Created a pull request. #12
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.