运行我的构建任务时,useref 没有按照我的预期执行:
在我的索引中,我有:
<!-- build:css /assets/styles/lib.css -->
<!-- bower:css -->
<link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap.css" />
<!-- endbower -->
<!-- endbuild -->
<!-- build:css /assets/styles/main.css -->
<!-- inject:css -->
<link rel="stylesheet" href="assets/styles/main.css">
<!-- endinject -->
<!-- endbuild -->
<!-- build:js /lib.js -->
<!-- bower:js -->
<script src="/bower_components/jquery/dist/jquery.js"></script>
<script src="/bower_components/angular/angular.js"></script>
<!-- endbower -->
<!-- endbuild -->
<!-- build:js ./project.js -->
<!-- inject:js -->
<script src="app.js"></script>
<!-- endinject -->
<!-- endbuild -->
所以在我的 gruntfile 我有一个任务:
gulp.task('build-optimise', function () {
log('Optimising project');
return gulp.src(config.app + 'index.html')
.pipe($.useref({searchPath: ['./bower_components', config.app]}))
.pipe($.print())
.pipe($.if('*.js', $.uglify({
mangle: false
})))
.pipe($.if('*.css', $.minifyCss()))
.pipe(gulp.dest(config.dist));
}); // config.app = ./local which contains my local build
运行我的任务时,它会生成一个 lib.js 文件和一个 assets/styles/lib.css 文件,但没有 project.js 和 assets/styles/main.css
我怎样才能解决这个问题?我的 js 文件是用 typescript 编写的,并且已经过检查并成功创建,css 来自 sass,我很确定它们没有错误,所以它一定是别的东西......