我试图通过运行任务将所有css文件连接成一个已发布的css文件:
gulp.task('task one', () => {
gulp.src([Dir + "**/*.css"])
.pipe(concat(outFilename + ".css"))
.pipe(gulp.dest(destDir));
});
之后,因为输出css文件中的字体路径不正确,所以我需要修改路径。
gulp.task('task two', () => {
var urlAdjuster = require('gulp-css-url-adjuster');
//change font path for released css files
gulp.src([releasePath + "/*.css"])
.pipe(urlAdjuster({
replace: ['../../fonts', '../fonts'],
}))
.pipe(gulp.dest(releasePath + "/"));
);
为了实现这一目标,我需要逐个分别运行这两个任务。 如何按顺序运行这两个任务并将它们放入一个任务中。
我试过了:
series = require('gulp-series');
----无法正常工作
gulp.task('task two', ['task one'], function () {
// Gulp. src (...
});
-----不工作
---更新------------------------------------------- ------------- 我使用了返回,但它现在正在工作。实际代码是:
function procHTMLForRelease(stream, file) {
gulp.src([Dir + "**/*.css"])
.pipe(concat(outFilename + ".css"))
.pipe(gulp.dest(destDir));
}
function processRelease() {
// Grab all html files in the folder.
// Loop over them, process them, then spit em out.
gulp.src([paths.Source + "/*.html"])
.pipe(foreach(procHTMLForRelease))
.pipe(gulp.dest(paths.Release));
// Process image files
gulp.src([paths.Source + "images/*.*"])
.pipe(gulp.dest(paths.Release + "images/"));
// Copy font files
gulp.src([paths.html + "fonts/*.*", paths.html + "fonts/*/*.*"])
.pipe(gulp.dest(paths.release + "/fonts/"));
}
gulp.task('task one', () => { return processRelease();
});
答案 0 :(得分:0)
// Model file
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class User_model extends CI_Model
{
public function insertuser($data)
{
return $this->db->insert('candidates', $data);
}
public function verifyemail($key)
{
$this->db->where('md5(email)', $key);
return $this->db->update('candidates', $data);
}
public function check_user($email,$pass)
{
$sql = "SELECT id , fname FROM candidates where email = ? and password = ?";
$data = $this->db->query($sql, array($email,$pass));
return ($data->result_array()) ;
}
// Function To Fetch Selected Record
public function show_user_id($data){
$this->db->select('*');
$this->db->from('candidates');
$this->db->where('email', $data);
$q=$this->db->get('candidates');
return $q->row_array();
}
// Update Query For Selected Student
public function update_user_id1($id,$data){
$this->db->where('email', $id);
$this->db->update('candidates', $data);
}
}
?>
这是正确的,它将gulp.task('task two', ['task one'], function () {
// gulp.src( ...
});
设置为task one
的依赖项。但是,要实现此目的,task two
需要task one
。
return
答案 1 :(得分:0)
您可以像这样修改更新的代码,使其成为return
。
gulp.task('taks one', function () {
// Grab all html files in the folder.
// Loop over them, process them, then spit em out.
var one = gulp.src([paths.Source + "/*.html"])
.pipe(foreach(procHTMLForRelease))
.pipe(gulp.dest(paths.Release));
// Process image files
var two = gulp.src([paths.Source + "images/*.*"])
.pipe(gulp.dest(paths.Release + "images/"));
// Copy font files
var three = gulp.src([paths.html + "fonts/*.*", paths.html + "fonts/*/*.*"])
.pipe(gulp.dest(paths.release + "/fonts/"));
// Return
return [ one, two, three];
});
函数内部的任务将以异步方式运行,但您可以创建另一个函数来依赖所有已完成的任务。
gulp.task('task two', ['task one'], function () {
// Gulp. src (...
});
答案 2 :(得分:-1)
对于任何人都有同样的问题并寻找解决方案: 以下是我要解决的问题: https://www.npmjs.com/package/run-sequence
例如:
// This will run in this order:
// * build-clean
// * build-scripts and build-styles in parallel
// * build-html
// * Finally call the callback function
gulp.task('build', function(callback) {
runSequence('build-clean',
['build-scripts', 'build-styles'],
'build-html',
callback);
});