douzao9845 2014-10-08 20:32 采纳率: 0%
浏览 40

扫描HTML以获取css和js链接,并在Gulp的任务中使用它们

Okay I am just throwing this out there. I have no knowlegde of PHP and little knowlegde of Javascript.

Is it possible to check an HTML file if header css/js links and body .js links exist?

And if yes: locate them and use them in a Gulp-task in the order they are added in the HTML file?

Example header:

<head>
<meta charset="utf-8">
<title>Website | Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="The Most Awesome" content="Website">
<link rel="stylesheet" type="text/css" href="css/normalize.css">
<link rel="stylesheet" type="text/css" href="css/barebone.css">
<link rel="stylesheet" type="text/css" href="css/custom.css"> 
</head>

Use those links in a Gulptask like:

gulp.task('css', function(){
 gulp.src("*links in html*")
.pipe(concat('main.css'))
.pipe(prefix())
.pipe(minifyCSS())
.pipe(gulp.dest('build/css'))
.pipe(connect.reload());
});

I could just declare the links in the Gulp-task but I want the Gulpfile to be as generic as possible. I want to be able to just dump my files anywhere in the folder.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 多址通信方式的抗噪声性能和系统容量对比
    • ¥15 winform的chart曲线生成时有凸起
    • ¥15 msix packaging tool打包问题
    • ¥15 finalshell节点的搭建代码和那个端口代码教程
    • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
    • ¥15 Centos / PETSc / PETGEM
    • ¥15 centos7.9 IPv6端口telnet和端口监控问题
    • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
    • ¥20 海浪数据 南海地区海况数据,波浪数据