【问题标题】:Gulp `build` not working as expected, gives only `index.html` as outputGulp `build` 没有按预期工作,只给出 `index.html` 作为输出
【发布时间】:2017-06-08 05:53:10
【问题描述】:

我正在使用gulp 打包我的应用程序。但我只得到index.html 作为输出。

我无法看到 vendar.js,app.js 文件以及在 index.html 文件中添加的所有 css 文件。

我的期望是:

index.html href 和 src 获取所有文件。从那里按序列压缩索引文件中的内容并发送到dest文件夹。

这是我的代码:

var gulp = require("gulp");
var ghtmlSrc = require('gulp-html-src');
var templateCache = require("gulp-angular-templatecache");
var gulpif = require('gulp-if');
var ngAnnotate = require('gulp-ng-annotate');
var minifyCss = require('gulp-minify-css');
var useref = require('gulp-useref');
var uglify = require('gulp-uglify');

gulp.task('templates', function() {
    return gulp.src('./WebContent/src/**/*.html')
    .pipe(templateCache({
        root:'src/',
        module: 'newPCSApp.templates',
        standalone: true
    }))
    .pipe(gulp.dest('WebContent/src/app/'));
});

gulp.task('compress', function() {
            return gulp.src('./WebContent/index.html')
            .pipe(useref())
            .pipe(gulpif('*.js', ngAnnotate()))
            .pipe(gulpif('*.js', uglify({ mangle: false })))
            .pipe(gulpif('*.css', minifyCss()))
            .pipe(gulp.dest('./dist'));
        });


gulp.task('build',['templates', 'compress' ]);

【问题讨论】:

    标签: gulp gulp-uglify gulp-useref


    【解决方案1】:

    在我将注释行添加到 html 文件后,问题已解决。

    <!--build:css css/style.min.css --> <!-- endbuild --> <!-- build:js js/vendor.min.js --> <!-- endbuild --> <!-- build:js js/app.min.js --> <!-- endbuild -->

    【讨论】:

      猜你喜欢
      • 2016-10-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-31
      • 2023-01-18
      • 2018-11-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多