gulp-rev在目标目录中创建一个目录

时间:2016-07-13 21:29:11

标签: javascript gulp gulp-rev

首先,我想说Gulp(对我而言)正在制造更多问题而不是解决问题。

我写了一个gulp文件,它连接了一些CSS文件并将它们放在一个目录中。此任务的代码如下:

var config = {
    mainDir: 'app/assets'
};

config.stylesFiles = [
    'bower_resources/admin-lte/dist/css/AdminLTE.min.css',
    'bower_resources/admin-lte/dist/css/skins/_all-skins.min.css',
    'css/app.css'
];

....

gulp.task('styles', function() {
    return gulp
        .src(config.stylesFiles, { cwd: config.mainDir })
        .pipe(sourcemaps.init())
            .pipe(concat('theme.css'))
        .pipe(sourcemaps.write('../build/css'))
        .pipe(gulp.dest('public/css/'))
        .on('end', function() { gutil.log('Styles copied') });
});

这很简单,效果很好。

但是,我想对这个生成的文件进行版本控制。所以我写了一个特定的任务来做到这一点:

....

config.manifestFolder = process.cwd() + '/public/build';

gulp.task('versionCSS', function() {
    return gulp
        .src(['css/theme.css'], { cwd: 'public' })
        .pipe(rev())
        .pipe(gulp.dest('public/build/css'))
        .pipe(rev.manifest( 
            {
                base: config.manifestFolder, 
                cwd: config.manifestFolder, 
                merge: true 
            } 
         ))
        .pipe(gulp.dest(config.manifestFolder))
        .on('end', function() { gutil.log('CSS files versioned') });
});

问题是:当Gulp要运行此任务时,它会在目标文件夹中创建一个文件夹。

运行Gulp之后,我得到了这个结构:

- public
  - build
    - css (destination folder for the versioned file)
      - css (folder created by Gulp)
        - versioned file that should be in the parent folder
  - css
    - concatenated file without version

我真的不知道该怎么做了。我已经为cwdbase函数设置了destsrc选项,更改了目标,同步了任务等等。没有什么能解决这种愚蠢的行为

0 个答案:

没有答案
相关问题