我的 gulp usemin 任务缺少一个 js 文件

My gulp usemin task missing a js file

本文关键字:一个 js 文件 usemin gulp 任务 我的      更新时间:2023-09-26

我正在使用gulp usemin任务来组合和最小化/丑化HTML中的css和js文件。

gulp.task('usemin',['jshint'], function () {
  return gulp.src('./app/**/*.html')
      .pipe(usemin({
        css:[minifycss(),rev()],
        js: [uglify(),rev()]
      }))
      .pipe(gulp.dest('dist/'));
});

还有我在 HTML 中的块:

<!-- build:css styles/main.css -->
<link href="../bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="../bower_components/bootstrap/dist/css/bootstrap-theme.min.css" rel="stylesheet">
<link href="styles/home.css" rel="stylesheet">
<link href="../bower_components/font-awesome/css/font-awesome.min.css" rel="stylesheet">
<!-- endbuild -->
<!-- build:js scripts/main.js -->
<script src="../bower_components/jquery/dist/jquery.min.js"></script>
<script src="../bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="../bower_components/angular/angular.min.js"></script>
<script src="../bower_components/jquery-ui/jquery-ui.min.js"></script>
<script src="scripts/home.js"></script>
<script src="scripts/controllers.js"></script>
<!-- endbuild -->

但是在我这样做之后。 在dist/中,所有其他部分都像在app/中一样工作得很好,但jquery-ui.js。我的页面中的彩色动画不起作用,这是由于jquery-ui。

文件结构:文件结构

这怎么可能?只有一个 js 文件不起作用,但其他文件工作正常?

我自己发现的。我需要将用于彩色动画的 jquery-ui css 文件添加到 HTML 中,如下所示:

<!-- build:css styles/main.css -->
<link href="../bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="../bower_components/bootstrap/dist/css/bootstrap-theme.min.css" rel="stylesheet">
<link href="../bower_components/font-awesome/css/font-awesome.min.css" rel="stylesheet">
<link rel="stylesheet" href="../bower_components/jquery-ui/themes/smoothness/jquery-ui.min.css">
<link href="styles/home.css" rel="stylesheet">
<link href="styles/timeline.css" rel="stylesheet">
<!-- endbuild -->

但是我仍然不确定为什么在最小化CSS文件之前我可以毫无问题地使用jquery-ui。