1

对于 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}}" />'
          }
        }
      }
    }));

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

4

1 回答 1

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'));
于 2014-10-13T18:05:19.183 回答