【问题标题】:gulp-html-minify .pipe destination to original folder structuregulp-html-minify .pipe 目标到原始文件夹结构
【发布时间】:2016-11-11 01:05:28
【问题描述】:

北方人你好,我正在尝试使用 gulp 缩小我的 HTML,因为https://developers.google.com/speed/pagespeed/insights 告诉我我的网站太慢了。

我原来的html文件的结构是

/app/blog/page1.html
/app/contact/contactus.html
/app/xxx/xxx.html

使用我当前的代码,gulp 输出会将所有 html 文件放入 _build 文件夹中,但这对我不起作用,因为在页面加载时它会在相应文件夹中查找 html。我应该/我可以将缩小后的 html 放在其原始文件夹中,以便正常自动引用它吗?

 gulp.task('minify-html', function () {
            return gulp.src(configHTML.src)
                .pipe(angularify())
                .pipe(minifyHTML())
                .pipe(gulp.dest('_build/'));
        });

【问题讨论】:

    标签: gulp


    【解决方案1】:

    有可能,您应该尝试更改您的代码:

    gulp.src(configHTML.src, { base: "." })        
        .pipe(htmlmin({ collapseWhitespace: true, minifyCSS: true, minifyJS: true }))
        .pipe(gulp.dest("."))
    

    这将缩小这些文件本身

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-08
      • 2014-11-09
      • 1970-01-01
      • 2015-04-06
      • 1970-01-01
      • 2014-04-02
      相关资源
      最近更新 更多