gulp-wiredep替换路径

时间:2014-10-13 17:09:13

标签: django gulp wiredep

对于django,我试图插入相对路径..

我旧的grunt文件的wiredep部分看起来像这样

wiredep: {
      dashboard: {
        src: '<%= backOffice.dashboard %>/base.html',
        exclude: ['/selectize/', '/sifter/', '/microplugin/'],
        ignorePath: '../../static/',
        fileTypes: {
          html: {
            replace: {
              js: '<script src="{{ STATIC_URL }}{{filePath}}"></script>',
              css: '<link rel="stylesheet" href="{{ STATIC_URL }}{{filePath}}" />'
            }
          }
        }
      }
    }

我正在尝试使用我的wiredep.js执行相同的gulp任务,这就是它的样子

'use strict';

var gulp = require('gulp');

// inject bower components
gulp.task('wiredep', function() {
  var wiredep = require('wiredep').stream;

  gulp.src('src/{app,components}/*.scss')
    .pipe(wiredep({
      directory: 'src/bower_components'
    }))
    .pipe(gulp.dest('src'));

  gulp.src('../../templates/backoffice/__base.html')
    .pipe(wiredep({
      fileTypes: {
        html: {
          replace: {
            js: '<script src="{{ STATIC_URL }}{{filePath}}"></script>',
            css: '<link rel="stylesheet" href="{{ STATIC_URL }}{{filePath}}" />'
          }
        }
      }
    }));

但这不起作用,有人可以帮忙吗?

1 个答案:

答案 0 :(得分:1)

得到答案,必须包含要创建的文件的gulp.dest。

gulp.src('../../templates/backoffice/__base.html')
    .pipe(wiredep({
      ignorePath: '../../static/',
      fileTypes: {
        html: {
          replace: {
            js: '<script src="{{ STATIC_URL }}{{filePath}}"></script>',
            css: '<link rel="stylesheet" href="{{ STATIC_URL }}{{filePath}}" />'
          }
        }
      }
    }))
    .pipe(gulp.dest('../../templates/backoffice'));