gulp

Karma: Running a single test file from command line

[亡魂溺海] 提交于 2019-12-17 17:33:54
问题 So, I've been looking all over for this, found "similar" answers here, but not exactly what I want. Right now if I want to test a single file with karma, I need to do fit() , fdescribe() on the file in question... However, what I do want is to be able to just call karma, with the config file, and direct it to a specific file, so I don't need to modify the file at all, ie: karma run --conf karma.conf.js --file /path/to/specific/test_file.js is it possible to do this? Or with any helper? (using

Object.assign is not a function

☆樱花仙子☆ 提交于 2019-12-17 15:59:11
问题 I'm using babel with gulp and create a simple DOM library in ES6. But after running and when i'm going to use it, I got the Object.assign is not a function in chrome console. this is the gulp code gulp.task('scripts', function() { return gulp.src(src + 'js/*.js') .pipe(babel()) .pipe(concat('main.js')) .pipe(gulp.dest(dest + 'js')); }); this is the class file class DOM { constructor( selector ) { var elements = document.querySelectorAll(selector); this.length = elements.length; Object.assign

Can I use a Gulp task with multiple sources and multiple destinations?

一个人想着一个人 提交于 2019-12-17 15:34:22
问题 I have the following in my gulpfile.js: var sass_paths = [ './httpdocs-site1/media/sass/**/*.scss', './httpdocs-site2/media/sass/**/*.scss', './httpdocs-site3/media/sass/**/*.scss' ]; gulp.task('sass', function() { return gulp.src(sass_paths) .pipe(sass({errLogToConsole: true})) .pipe(autoprefixer('last 4 version')) .pipe(minifyCSS({keepBreaks:true})) .pipe(rename({ suffix: '.min'})) .pipe(gulp.dest(???)); }); I'm wanting to output my minified css files to the following paths: ./httpdocs

Gulp TypeError: Arguments to path.join must be strings

人盡茶涼 提交于 2019-12-17 10:24:49
问题 I have i problem with gulp-ruby-sass. When i try to run the watch task and change some .sass files it occurs error: TypeError: Arguments to path.join must be strings Here is my gulpfile.js var gulp = require('gulp'); var jade = require('gulp-jade'); var sass = require('gulp-ruby-sass'); var watch = require('gulp-watch'); gulp.task('sass', function() { return gulp.src('sass/*.sass') .pipe(sass()) .pipe(gulp.dest('./css')); }); gulp.task('watch', function() { gulp.watch('./sass/*.sass', ['sass'

creating tasks using a loop [gulp]

陌路散爱 提交于 2019-12-17 09:35:50
问题 I'm trying to dynamically create tasks (minify and concat) based on jsFiles object. The key will give the destination file name and the array contains the src files . When I run gulp I see all the tasks names being ran but it only writes the last key which is group2.js in this case. What's wrong here? // imports here var jsFiles = { group1:[file1.js,file2.js], group2:[file2.js,file3.js] }; for (var key in jsFiles) { gulp.task(key, function() { return gulp.src(jsFiles[key]) .pipe(jshint())

Using Gulp to Concatenate and Uglify files

十年热恋 提交于 2019-12-17 04:39:30
问题 I'm trying to use Gulp to: Take 3 specific javascript files, concatenate them, then save the result to a file (concat.js) Take this concatenated file and uglify/minify it, then save the result to another file (uglify.js) I have the following code so far var gulp = require('gulp'), gp_concat = require('gulp-concat'), gp_uglify = require('gulp-uglify'); gulp.task('js-fef', function(){ return gulp.src(['file1.js', 'file2.js', 'file3.js']) .pipe(gp_concat('concat.js')) .pipe(gp_uglify()) .pipe

学习自动化工具gulp

和自甴很熟 提交于 2019-12-16 20:35:22
<什么是gulp> 官网地址:http://gulpjs.com/   gulp是可以自动化执行任务的工具,在开发流程里,一定有一些动作需要手工的重复的去执行,例如:   ·把一个文件拷贝到另外一个位置   ·把多个js或者css文件合并成一个文件,以减少网络请求数,同时可以进行压缩,去掉空格回车等浏览器不需要的部分   ·把sass或者less文件编译为css   ·压缩图像文件,以减少网络流量   ·创建一个可以实时刷新页面内容的本地服务器等等 一般需要重复执行的动作,都可以创建成一个gulp任务,然后在指定的条件下,比如文件发生变化后,自动去执行这些任务 <gulp的特点>   ·易于使用 通过代码优于配置的策略,gulp让简单的任务简单,复杂的任务可管理   ·快速构建 利用nodejs流的威力,可以快速的构建项目并减少频繁的IO操作,前一级的输出,直接变成后一级的输入,使得在操作上非常简单   ·高质量的插件 gulp严格的插件指南确保插件可以简洁的工作   ·易于学习 API很少(核心方法也就4个) 对比grunt与gulp,用一辆载有货物的火车说明:grunt就好比每次在中转站,都要将车上的货物卸下来,再换量新的火车(有较多的临时文件等);而gulp就好比在中转站的时候,只需要更换新的车头就可以,不需要重新的卸货装货的步骤。 <gulp中的流>   

gulp API

狂风中的少年 提交于 2019-12-16 18:02:02
1、gulp.src(globs[, options]) 1.1、说明:src方法是指定需要处理的源文件的路径,gulp借鉴了Unix操作系统的管道(pipe)思想,前一级的输出,直接变成后一级的输入,gulp.src返回当前文件流至可用插件; 1.2、 globs : 需要处理的源文件匹配符路径。类型(必填): String or StringArray; 通配符路径匹配示例: “src/a.js”:指定具体文件; “*”:匹配所有文件 例:src/*.js(包含src下的所有js文件); “**”:匹配0个或多个子文件夹 例:src/**/*.js(包含src的0个或多个子文件夹下的js文件); “{}”:匹配多个属性 例:src/{a,b}.js(包含a.js和b.js文件) src/*.{jpg,png,gif}(src下的所有jpg/png/gif文件); “!”:排除文件 例:!src/a.js(不包含src下的a.js文件); 1 var gulp = require('gulp'), 2 less = require('gulp-less'); 3 4 gulp.task('testLess', function () { 5 //gulp.src('less/test/style.less') 6 gulp.src(['less/**/*.less','!less

Gulp 搭建前端非SPA 项目

≯℡__Kan透↙ 提交于 2019-12-16 09:37:12
起因:需要搭建一个自动打包处理 sass / js (es6),自动监听文件变化时浏览器自动刷新的开发环境 先放 gulpfile.js 文件,其他的详细配置稍后再介绍 const { src, dest, parallel,series, watch } = require('gulp'); const sass = require('gulp-sass'); const less = require('gulp-less'); const minifyCSS = require('gulp-csso'); const concat = require('gulp-concat'); const babel = require('gulp-babel'); const autoprefixer = require('gulp-autoprefixer') const browserSync = require('browser-sync').create() sass.compiler = require('node-sass'); // Static server async function serve() { await browserSync.init( { server: { baseDir: './build', } } ) } // html 复制 function

Gulp.js

邮差的信 提交于 2019-12-14 16:17:54
Gulp.js 是一个自动化构建工具,开发者可以使用它在项目开发过程中自动执行常见任务。Gulp.js 是基于 Node.js 构建的,利用 Node.js 流的威力,你可以快速构建项目. 为什么要用Node环境: js是一个脚本文件,不能直接用来操作文件。但是,在项目过程中,免不了需要经常操作一些文件,包括移动复制压缩上传修改等。如果重新学习C之类底层操作的语言的未免成本太高,此时node的横空出世,解决了这个问题。因为node使用了js的语法,而且使用js的人也越来越多,node就理所当然的火遍大江南北 在node中有很多插件,类似于手机中的软件,拿到一个新手机没有任何软件是没有办法使用的。 gulp就是node中的工具之一。类似前端工程化工具还有:webpack,grunt,browserify。 gulp是一种前端自动化工具,在使用gulp之前需要先安装gulp 安装gulp有两种方式,一种是通过下载软件安装,一种是通过类似手机的应用商店的软件下载,而node就是这个应用商店 直接在网页上下载安装不仅安全性无法保证,而且还会造成不兼容等问题; 通过手机的应用商店下载的软件会自动适配当前手机的型号和cpu等信息,既保证了安全,也保证的软件的功能完整性 配置nodejs 在配置gulp环境之前需要有node环境, 去官网下载node node是一个命令行工具