【问题标题】:Gulp how to write path's?gulp怎么写路径的?
【发布时间】:2019-10-28 08:38:20
【问题描述】:

我正在使用 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

【问题讨论】:

    标签: javascript html gulp


    【解决方案1】:

    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 而不是所有图像。

    【讨论】:

    • 注意:/fonts/**/*.tff 会检查字体文件夹中的所有文件夹和tff字体。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-13
    • 1970-01-01
    • 2012-01-27
    相关资源
    最近更新 更多