Gulp怎么写路径的?

时间:2019-10-28 08:38:20

标签: javascript html gulp

我正在使用gulp,但我感到困惑,在构建后,我的所有路径都是错误的。

例如:

SRC : 

pages -> home.html, buy.html  (src="../assets/img/test/test.png" used to get all images)
partials -> navigation.html, footer.html
assets -> js,scss,img folders
layouts -> layout.html

建筑后:

DIST : 

assets -> js,css,img folders
home.html (with ../assets.... url's) - dont work, wrong path
buy.html (with ../assets.... url's) - dont work, wrong path

1 个答案:

答案 0 :(得分:0)

您在gulpfile.js中的路径应如下所示:

'use strict'

var gulp = require('gulp')
var fontmin = require('gulp-fontmin')
// ...

gulp.task('fonts:parent', function () {
    return gulp.src('./builder/site/parent/fonts/**/*.ttf')
        .pipe(fontmin())
        .pipe(gulp.dest('./final/frame/themes/gate/assets/fonts'))
});

// Watch
gulp.task('gulp:watch', [
  'fonts:parent',
  ], function() {
  gulp.watch('./builder/site/parent/fonts/**/*.ttf', ['fonts:parent'])
});

gulp.task('default', ['gulp:watch'])

/test.png与/*.png仅检查test.png而不是所有图像。