javascript - gulp-inject的使用方式
大家讲道理
大家讲道理 2017-04-10 16:16:30
[JavaScript讨论组]

关于gulp-inject的使用方式,今天使用gulp构建项目,使用到了gulp-inject自动插入静态文件到html,但是纠结啦。

正常的使用方式




  My index
  
  



  
  

var gulp = require('gulp');
var inject = require('gulp-inject');

gulp.task('index', function () {
  var target = gulp.src('./src/index.html');
  // It's not necessary to read the files (will speed up things), we're only after their paths:
  var sources = gulp.src(['./src/**/*.js', './src/**/*.css'], {read: false});

  return target.pipe(inject(sources))
    .pipe(gulp.dest('./src'));
});



  My index
  
  
  
  



  
  
  
  

但是有个问题,这样的话,他会把全部的js跟css文件添加上去,我现在想要的是,比如index.html页面,只单独引入index.js和index.css,其他的就是公用的引入在一起比如,comm.js comm.css等,我希望是这样:




  My index
  
  
  
  



  
  
  
  

我该怎么配置,或者该怎么写注解??真心求教。

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号