gulp

How can I use Gulp to add a line of text to a file

[亡魂溺海] 提交于 2019-12-18 03:57:41
问题 I've been trying to figure out how to add a line of text to any type of file using Gulp. For instance add: @import 'plugins' to my main.sass file. Or add a CDN to an index.html file. I did try: gulp.task('inject-plugins', function(){ gulp.src('src/css/main.sass') .pipe(inject.after('// Add Imports', '\n@import \'plugins\'\n')); }); with no joy. Any idea how I could achieve this please? 回答1: Depends on what you want to do. If you just want to add text to the beginning or end of a file gulp

Iterating over directories with Gulp?

牧云@^-^@ 提交于 2019-12-17 22:39:04
问题 I'm new to gulp, but I'm wondering if its possible to iterate through directories in a gulp task. Here's what I mean, I know a lot of the tutorials / demos show processing a bunch of JavaScript files using something like "**/*.js" and then they compile it into a single JavaScript file. But I want to iterate over a set of directories, and compile each directory into it's own JS file. For instance, I have a file structure like: /js/feature1/something.js /js/feature1/else.js /js/feature1/foo/bar

How to add src files in the middle of a pipe

人盡茶涼 提交于 2019-12-17 22:38:38
问题 I want to process some files with 'coffee', add some js files, concat and minify. This does not work, coffee fails on the regular js files: gulp.task 'build-js', -> gulp.src([ "bower_components/mbdev-core/dist/js/db.js" "bower_components/mbdev-core/dist/js/utils.js" "src/js/config/app.coffee" "src/js/config/app-db.coffee" "src/js/accounts/accounts.coffee" "src/js/budget_items/budget_items.coffee" "src/js/line_items/line_items.coffee" "src/js/misc/misc.coffee" "src/js/reports/report_generators

How to Gulp-Watch Multiple files?

不想你离开。 提交于 2019-12-17 21:54:35
问题 I have something like this: gulp.task('default', ['css', 'browser-sync'] , function() { gulp.watch(['sass/**/*.scss', 'layouts/*.css'], function() { gulp.run('css'); }); }); but it does not work, because it watches two directories, the sass and the layouts directory for changes. How do I make it work, so that gulp watches anything that happens inside those directories? 回答1: gulp.task('default', ['css', 'browser-sync'] , function() { gulp.watch(['sass/**/*.scss', 'layouts/**/*.css'], ['css']);

How to organize full build pipeline with Gulp, Maven and Jenkins, all the way to integration tests?

岁酱吖の 提交于 2019-12-17 21:47:13
问题 I have a project that has: JS client with somewhat interesting build process. That includes compiling CSS, catenating and minifying JS and CSS, generating and processing HTML, and some other steps. The Node tools like Grunt or Gulp are great at this. Java server that is a WAR deployed on Tomcat. It includes these assets as well as all the Java code. It has all kinds of tests: Unit tests, integration tests that may instantiate a DAO and talk to DB, and end-to-end API tests that actually talk

Could Node feasibly return a value from a function call before completing all operations within the function itself?

安稳与你 提交于 2019-12-17 21:35:10
问题 I'm having trouble understanding how Node operates regarding it's parallel processing and returning values from function calls. FYI: The gulp function below is merely created as an example for this question. Is it possible that the function could return the stream before the Read a large file statement has finished processing (the large file has been fully read from the file system and the stream has been added), or is Node smart enough to complete all statements before returning? function

gulp-watch in combination with gulp-less caching issue

孤街浪徒 提交于 2019-12-17 21:16:09
问题 I have the following setup: // watch for changes gulp.task('watch', function () { gulp.watch('./assets/**/*.less', ['compile-less']); }); gulp.task("compile-less", () => { return gulp.src('./assets/build-packages/*.less') .pipe($.less({ paths: [ $.path.join(__dirname, 'less', 'includes') ] })) .pipe(gulp.dest(OutputPath)); // ./dist/styles/ }); So basically every time a developer changes something in a less file it runs the task 'compile-less'. The task 'compile-less' builds our package less

Uglify throws Parse error

爷,独闯天下 提交于 2019-12-17 18:50:49
问题 When i use gulp-uglify with browserify i get a error events.js:72 throw er; // Unhandled 'error' event ^ Error at new JS_Parse_Error (/home/rkmax/my-project/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:189:18) at js_error (/home/rkmax/my-project/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:197:11) at croak (/home/rkmax/my-project/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:656:9) at token_error (/home/rkmax/my-project/node_modules/gulp-uglify

Gulp - Target all files in a folder and its subfolders

試著忘記壹切 提交于 2019-12-17 18:16:09
问题 I'd like to be able to add a watch task in gulp to all of the js files in the frontend/js and any other js files below gulp.watch('./frontend/js/**/*.js', ['browserify']); This will only target js files one folder deep 回答1: It's supposed to match any number of subdirectories: ** If a "globstar" is alone in a path portion, then it matches zero or more directories and subdirectories searching for matches. It does not crawl symlinked directories. https://github.com/isaacs/node-glob Do you have

gulp-newer vs gulp-changed

谁都会走 提交于 2019-12-17 17:47:07
问题 What're the differences between them? gulp-newer: gulp.src(imgSrc) .pipe(newer(imgDest)) .pipe(imagemin()) .pipe(gulp.dest(imgDest)); gulp-changed: gulp.src(SRC) .pipe(changed(DEST)) // ngmin will only get the files that // changed since the last time it was run .pipe(ngmin()) .pipe(gulp.dest(DEST)); It seems gulp-changed is more powerful, because it provides an option hasChanged: changed.compareLastModifiedTime 回答1: I hope it's not too late to answer this question. I have had to evaluated