Tag: gulp

gulp sass源地图

我需要帮助添加源地图到SASS编译器在同一个CSS输出文件夹。 到目前为止,我已经在gulpfile.js安装了gulp-sourcemaps模块,但是无法成功地将sourcemaps.write绑定为gulp.task。 任何帮助深表感谢 :) var gulp = require('gulp'); var sass = require('gulp-sass'); var sourcemaps = require('gulp-sourcemaps'); var bs = require('browser-sync').create(); gulp.task('browser-sync', ['sass'], function() { bs.init({ server: { baseDir: "./" }, proxy: { target: "localhost:8080", // can be [virtual host, sub-directory, localhost with port] ws: true // enables websockets } }); }); gulp.task('sass', function() { return […]

如何debugginggulpfile.js

为了能够debugginggulpfile.js ,执行node-inspector的正确方法是什么? 我试过下面的代码(我的大文件中的代码需要harmony和harmony-arrow-functions switches ): node-debug –nodejs –harmony –nodejs –harmony-arrow-functions /home/user/.npm-packages/bin/gulp default 节点检查器已被正确加载,但不能在加载文件之前或之后在gulpfile中设置断点。 也不可能在gulp/index.js和orchestrator/index.js文件中设置断点。 这是不可能“步入”以下声明( 整个来源 ): gulpInst.start.apply(gulpInst, toRun); 环境: Fedora 21 x64 节点检查器v0.9.2 节点v0.12.0 吞 CLI版本3.8.11 本地版本3.8.11

Gulp:如何改变文件的修改时间

我有下面的任务和任务(浏览器同步之前)每一个运行我想改变一个文件的最后修改时间(该文件没有任何变化,我只需要改变最后修改的时间 – 替代壳“触摸”命令)。 有人可以告诉我什么是最简单的方法吗? 谢谢! gulp.task('sass', function() { return sass(pkg.sass.dir, {sourcemap: true, precision: 10}) .on('error', function (err) { onError(err); }) .pipe(autoprefixer({ browsers: ['last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'], cascade: true })) .pipe(gulp.dest(pkg.css.dir)) .pipe(browsersync.reload({stream:true})); });

如何使用gulp和mocha写入文件?

我有一个使用Mocha json记者的抽样任务。 我想写的JSON输出到一个文件。 将欣赏一些投入。 这是我的代码: var gulp = require('gulp'); var mocha = require('gulp-mocha'); var util = require('gulp-util'); gulp.task('myreport', function() { return gulp.src(['tests.js'], { read: false }) .pipe(mocha({ reporter: 'json' })) //how do I write this to a file? .on('error', util.log); });

Gulp不是将scss转换成css

在Visual Studio中,Gulp不会将我的scss文件转换为css 。 我得到的错误是: cmd.exe / c gulp –tasks-simple C:\ Users \ sam \ Documents \ Visual Studio 2017 \ Projects \ MyProject \ MyProject \ node_modules \ node-sass \ lib \ binding.js:15 throw new Error(errors.missingBinary ()); ^错误:缺less绑定C:\ Users \ sam \ Documents \ Visual Studio 2017 \ Projects \ MyProject \ MyProject \ node_modules […]

我怎样才能“中止”一口气build造

在我的gulp构build中,如果我的服务器unit testing失败,我想“中止”构build过程,但是我不知道如何完成此任务。 目前,我正在使用节点的request模块来运行一些服务器端unit testing,如下所示: gulp.task("run-server-tests", function(){ var serverTestUrl = "http://myurl"; // returns test results in json format request(serverTestUrl, function (error, response, body) { var responseData = JSON.parse(body); if(responseData.isSuccess){ console.log(responseData.message); // nice! continue with rest of build (js, css tasks, etc.) } else { open(serverTestUrl + "&render"); // show unit test failures // err…. gulp.abortProcessing(); ???? […]

Gulp Browsersync导致每个文件更改多次重新加载

我使用Gulp的浏览器同步,在特定的文件上执行一些任务。 每当我保存一个文件,我得到10 + [BS] Reloading Browsers…在我的terminal和性能是可以理解的laggy。 这是我的gulpfile: gulp.task('bowerJS', function() { gulp.src(lib.ext('js').files) .pipe(concat('lib.min.js')) .pipe(uglify()) .pipe(gulp.dest('app/assets/js')); }); gulp.task('bowerCSS', function() { gulp.src(lib.ext('css').files) .pipe(concat('lib.min.css')) .pipe(gulp.dest('app/assets/css/')); }); // Compile sass into CSS & auto-inject into browsers gulp.task('less', function() { gulp.src('./app/css/*.less') .pipe(less()) .pipe(autoprefixer({ browsers: ['last 2 versions'], cascade: false })) .pipe(gulp.dest('app/assets/css')) .pipe(browserSync.stream()); }); // Render Jade templates as HTML files gulp.task('templates', […]

如何使用对象列表作为吞噬源码stream

我知道,吞咽需要一个乙烯源stream才能正常工作,但有没有简单的方法来使用已经存在的乙烯基文件或JSON对象,而不是众所周知的gulp.src,只能采取globs?

Nodemon重启运行gulp任务

我在我的gulpfile中有以下代码 gulp.task('scripts', function () { gulp.src(paths.browserify) .pipe(browserify()) .pipe(gulp.dest('./build/js')) .pipe(refresh(server)); }); gulp.task('lint', function () { gulp.src(paths.js) .pipe(jshint()) .pipe(jshint.reporter(stylish)); }); gulp.task('nodemon', function () { nodemon({ script: 'app.js' }); }); 当Nodemon重新启动时,我需要运行脚本和lint任务。我有以下几点 gulp.task('nodemon', function () { nodemon({ script: 'app.js' }).on('restart', function () { gulp.run(['scripts', 'lint']); }); }); 现在不推荐使用Gulp.run(),那么如何使用Gulp和最佳实践来实现上述目标?

本地安装的gulp没有在命令行中运行?

我是nodejs和gulp的新东西。 我在一个nodejs项目上工作,我必须在所有的文件上运行jslint。 我正在用这个目的。 我的问题是,为了在cli上运行gulp,我不想在全局安装gulp,也不想更新我的pathvariables,所以我在我的项目中使用package.json文件在我的项目中安装了gulp和其他节点模块 cd myproject npm安装 由于我不想在世界范围内安装gulp,并且想运行本地gulp,所以我在我的package.json文件中添加了脚本,就像在这个问题中给出的那样 { "name": "", "version": "1.0.0", "main": "index.js", "private": true, "dependencies": { "async": "1.5.0" }, "devDependencies": { "gulp": "^3.9.0", "gulp-jslint": "^0.2.2" }, "scripts": { "gulp": "./node_modules/.bin/gulp" // is this correct? } } 添加我的myproject文件夹中添加gulpfile.js var gulp = require('gulp'); // include plug-ins var jslint = require('gulp-jslint'); // JS hint task […]