gulp

Providing data models to use in Gulp Nunjucks templates

江枫思渺然 提交于 2019-12-04 19:26:11
I'm looking to use Gulp to render my Nunjucks templates with either gulp-nunjucks or gulp-nunjucks-render . Is there a way I can pass one or a series of .json files to the templating package to use the JSON data in my nunjucks templates? Ideally I'd have a models/ directory with each page having corresponding page.json file with contents to be used in that template. I'd like to know if it's possible with either of the above plugins and if so how it can be implemented. Any examples for a single or series of .json files would be very useful. Look into using gulp-data https://www.npmjs.org

Gulp Watch is not working

你说的曾经没有我的故事 提交于 2019-12-04 19:03:34
问题 I'm new Gulp user, and I try simple script to watch compass, but it didn't work. But when I just run gulp compass gulp can compile it. Any ideas? Here my script: var gulp = require('gulp'), compass = require('gulp-compass'), // Compass gulp.task('compass', function() { gulp.src('./assets/scss/*.scss') .pipe(compass({ config_file: './config.rb', css: './assets/css', sass: './assets/scss' })) .pipe(gulp.dest('./assets/css')); }); // Default task gulp.task('default', function() { gulp.start(

gulp-mocha how to pass the compilers flag?

二次信任 提交于 2019-12-04 19:01:55
问题 I'm trying to use the gulp-mocha module but can't figure out a good way to pass over the compilers flag. Is there a way to include this in my gulp task? Maybe in a separate pipe somehow? Example if running mocha from command line (works fine) mocha --compilers .:my_compiler.js test/**/*.js Example if using gulp-mocha (but where can I specify a compiler)? gulp.task('test', function () { gulp.src(["test/**/*.js"], { read: false }) .pipe(mocha({ reporter: 'spec' })) .pipe(exit()); }); I don't

TypeError: glob pattern string required

谁说胖子不能爱 提交于 2019-12-04 18:54:12
问题 I'm trying to compile sass using gulp-ruby-sass but I'm getting TypeError: glob pattern string required . This is what my gulpfile.js looks like: var gulp = require('gulp'), sass = require('gulp-ruby-sass'); var paths = { sassSrcPath: ['Content/css/**/*.scss'], sassDestPath: ['build/css/'], sassImportsPath: ['Content/styleguide/'] }; // Styles Task gulp.task('styles', function () { gulp.src(paths.sassSrcPath) .pipe(sass({ style: 'compressed', loadPath: [paths.sassImportsPath] })) .pipe(gulp

Any equivalent gulp plugin for doing “grunt bower”?

有些话、适合烂在心里 提交于 2019-12-04 18:15:40
问题 With grunt , I could use command grunt bower (provided by grunt-bower-requirejs) to auto-generate RequireJS config file for my local bower components. Is there any plugin for gulp to perform similar task? 回答1: Mind that bowerRequireJS is an asynchronous function. So you would need to use a callback (or synchronously return a Promise) to mark that task as asynchronous like so: gulp.task('bower', function(callback) { var options = { baseUrl: 'src', config: 'src/app/require.config.js',

How to start Gulp watch task when I type npm start

。_饼干妹妹 提交于 2019-12-04 17:41:40
问题 I have a gulp.js file that includes: gulp.task('default', ['watch']); Which starts up the watch task gulp.task('watch', function(){ gulp.watch(productionScripts, ['autoConcat']); }); Then on any saved changes to files in productionScripts, the watch task will concat the files. What I would like to do, is in my package.json, I would like to spool up this watch when I type npm start (this already starts my node server). package.json "start": "node server.js", UPDATE -------- Ben(b3nj4m.com), I

How to fix “Task is not in your gulpfile” error when using npm link?

痞子三分冷 提交于 2019-12-04 17:38:19
问题 We have a bunch of applications sharing common gulp logic, so we made a gulp plugin that contains a bunch of custom tasks. However we'd like to avoid installing gulp+our plugin (along with half the internet) for each of the applications we develop. Ideally, I'd like to do: npm install -g gulp npm install -g <our gulp plugin> Then for each app, we'd simply have to do: npm link gulp npm link <our gulp plugin> Although this works, the problem is gulp no longer recognizes any of our custom gulp

前端自动化构建工具库之gulp

ぐ巨炮叔叔 提交于 2019-12-04 17:18:35
这是一款基于nodejs的前端自动化构建工具--gulp,以下是使用gulp的步骤: 1.安装主程序,在需要编译的目录输入 npm install gulp //安装gulp插件 2.安装常用插件 npm install del//清空目录或文件用的插件 npm install gulp-concat//连接css或js的插件 npm install gulp-cssmin//压缩css的插件 npm install gulp-uglify//压缩js的插件 3.配置gulpfile.js,如果工作目录下没有该文件,请新建gulpfile.js,以下为一个常用的参考代码 /** * @author xialei <xialeistudio@gmail.com> */ (function () { "use strict"; /** * 加载插件 * @type {exports} */ var gulp = require('gulp'); var del = require('del'); var cssmin = require('gulp-cssmin'); var concat = require('gulp-concat'); var uglify = require('gulp-uglify'); /** * 清空目录的命令 */ gulp.task('clean',

使用gulp构建前端(二)

久未见 提交于 2019-12-04 17:18:20
使用gulp构建前端(二) 在使用gulp构建前端(一)文章中已经搭建了整个gulp的使用环境,现在我们来开始使用一些简单的插件的进行整个项目的编译过程。 插件一 使用gulp-imagemin压缩图片文件(包括PNG、JPEG、GIF和SVG图片) 还是进入项目目录本地安装gulp-imagemin npm install gulp-imagemin --save-dev 查看package.json文件是否添加了依赖,熟练过后就不用查看了,排查错误的时候可以这样。 { "name": "chen", "version": "1.0.0", "description": "", "main": "build/index.html", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "chen", "license": "ISC", "devDependencies": { "gulp": "^3.9.1", "gulp-imagemin": "^3.0.1" } } 开始在gulpfile.js文件中开始编写 var gulp = require('gulp'), //本地安装gulp所用到的地方 imagemin = require('gulp-imagemin');

How to cover React jsx files in Istanbul?

我是研究僧i 提交于 2019-12-04 16:34:36
问题 I'm trying to integrate my existing test processes to now include React, but am struggling on the code coverage part. I've been able to get my unit tests working fine by following this project/tutorial - https://github.com/danvk/mocha-react - http://www.hammerlab.org/2015/02/14/testing-react-web-apps-with-mocha/ I've been using Istanbul to cover my node code and it's working pretty well. However, I'm having trouble getting it to cover the jsx files that I'm using in my tests. Here's an