Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gulp 从html块中截取管道脚本,并动态设置html块的替换名称_Gulp_Gulp Useref_Gulp Html Replace - Fatal编程技术网

Gulp 从html块中截取管道脚本,并动态设置html块的替换名称

Gulp 从html块中截取管道脚本,并动态设置html块的替换名称,gulp,gulp-useref,gulp-html-replace,Gulp,Gulp Useref,Gulp Html Replace,也许有人能给我指出解决办法 我有几个带有脚本标记的HTML文件。我需要 管道引用的脚本文件 用动态路径替换html文件中的块 我尝试使用gulp useref,它做了我需要的一切,但它不允许动态更改替换脚本名称(必须在html注释中声明) 另一个插件gulp html replace完全满足了我的替换需求,但根本不使用管道引用脚本 解决此类任务的常见方法是什么?因为这似乎并不奇怪。提前感谢。最后决定同时使用这两种方法 HTML: <!-- build:js_replace --> &

也许有人能给我指出解决办法

我有几个带有脚本标记的HTML文件。我需要

  • 管道引用的脚本文件
  • 用动态路径替换html文件中的块
  • 我尝试使用gulp useref,它做了我需要的一切,但它不允许动态更改替换脚本名称(必须在html注释中声明)

    另一个插件gulp html replace完全满足了我的替换需求,但根本不使用管道引用脚本


    解决此类任务的常见方法是什么?因为这似乎并不奇怪。提前感谢。

    最后决定同时使用这两种方法

    HTML:

    <!-- build:js_replace -->
    <!-- build:js INTERMEDIATE.js -->
        <script type="text/javascript" src="scripts/script1.js"></script>
        <script type="text/javascript" src="scripts/script2.js"></script>
    <!-- endbuild -->
    <!-- endbuild -->
    
    gulp.src(dirName + '/*.html')
    .pipe(useref({}))
    .pipe(gif("**/*.js", rename(function (filePath) {
        filePath.basename = "someotherfilename";
    })))
    
    // ... Upload to cloud storage
    
    .pipe(gif("**/*.html", htmlreplace({
        js_replace: CLOUD_STORAGE_URL + "/scripts/someotherfilename.js"
    })))
    .pipe(gif("**/*.html", gulp.dest("./build/")));