<i id='kNCT4'><tr id='kNCT4'><dt id='kNCT4'><q id='kNCT4'><span id='kNCT4'><b id='kNCT4'><form id='kNCT4'><ins id='kNCT4'></ins><ul id='kNCT4'></ul><sub id='kNCT4'></sub></form><legend id='kNCT4'></legend><bdo id='kNCT4'><pre id='kNCT4'><center id='kNCT4'></center></pre></bdo></b><th id='kNCT4'></th></span></q></dt></tr></i><div id='kNCT4'><tfoot id='kNCT4'></tfoot><dl id='kNCT4'><fieldset id='kNCT4'></fieldset></dl></div>

      1. <small id='kNCT4'></small><noframes id='kNCT4'>

      2. <legend id='kNCT4'><style id='kNCT4'><dir id='kNCT4'><q id='kNCT4'></q></dir></style></legend>
      3. <tfoot id='kNCT4'></tfoot>
          <bdo id='kNCT4'></bdo><ul id='kNCT4'></ul>

      4. 无法让 gulp-rev-replace 与 gulp-useref 一起使用

        时间:2023-05-29

      5. <small id='vup66'></small><noframes id='vup66'>

        1. <tfoot id='vup66'></tfoot>

          <i id='vup66'><tr id='vup66'><dt id='vup66'><q id='vup66'><span id='vup66'><b id='vup66'><form id='vup66'><ins id='vup66'></ins><ul id='vup66'></ul><sub id='vup66'></sub></form><legend id='vup66'></legend><bdo id='vup66'><pre id='vup66'><center id='vup66'></center></pre></bdo></b><th id='vup66'></th></span></q></dt></tr></i><div id='vup66'><tfoot id='vup66'></tfoot><dl id='vup66'><fieldset id='vup66'></fieldset></dl></div>
            <tbody id='vup66'></tbody>
          <legend id='vup66'><style id='vup66'><dir id='vup66'><q id='vup66'></q></dir></style></legend>

                • <bdo id='vup66'></bdo><ul id='vup66'></ul>
                  本文介绍了无法让 gulp-rev-replace 与 gulp-useref 一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  继续我之前的 问题 - 但这次是下一步:让文件修订工作.

                  Continuing my previous question - but this time is the next step: getting file revisions to work.

                  我正在学习 johnpapa 的 Gulp 自动化课程,但似乎遇到了另一面墙(当您尝试将简明课程调整为不同的文件结构时,您会遇到这种情况:P).

                  I'm working through johnpapa's course on automation with Gulp and seem to hit another wall (that's what you get when you try to adapt a concise course to a different file structure :P ).

                  基本上,问题是我确实得到了带有修订名称的文件,但是这些名称没有进入最终结果 test.jsp,我不知道为什么...

                  Basically, the issue is that I do get files named with a revision, but those names do not get into the end-result test.jsp, and I can't figure out why...

                  这是任务(为简洁起见省略了缩小,但它适用于文件修订):

                  This is the task (the minification is omitted for brevity, but it works fine with the file revisioning):

                  gulp.task('build-dev', ['inject'], function () {
                  
                      var assets = $.useref.assets({searchPath: ''});
                  
                      return gulp
                          .src(config.indexFile)
                          .pipe($.rename('test.jsp'))
                          .pipe($.plumber())
                          .pipe(assets)
                          .pipe($.rev())
                          .pipe(assets.restore())
                          .pipe($.useref())
                          .pipe($.revReplace({modifyUnreved: replaceDirectory, modifyReved: replaceDirectory}))
                          .pipe(gulp.dest(config.indexLocation))
                          .pipe($.rev.manifest())
                          .pipe(gulp.dest(config.indexLocation))
                          ;
                  });
                  

                  inject 是将css和js引用注入索引文件的任务(正常工作),$require('gulp-load-plugins')({lazy: true})config.indexFileindex.jsp.

                  inject is the task that injects css and js references to the index file (works correctly), $ is require('gulp-load-plugins')({lazy: true}) and config.indexFile is index.jsp.

                  replaceDirectory 函数是(使用因为 rev-manifest 生成完整路径名):

                  The replaceDirectory function is (used since the rev-manifest generates full pathnames):

                  function replaceDirectory(path) {
                  
                      var strToReplace = '../..';
                      var strToReplaceWith = process.cwd().replace(/\/g, '/') + '/WebContent';
                  
                      if (path) {
                          return path.replace(strToReplace, strToReplaceWith);
                      } else {
                          return path;
                      }
                  }
                  

                  我的文件结构(与课程中的不同)是:

                  My file structure (unlike the one in the course) is:

                  - ModuleDir
                      - dist
                          - css
                              - lib.css
                              - app.css
                          - fonts
                          - images
                          - js
                              - lib.js
                              - app.js
                      - css
                      - js
                      - web-app
                          - InnerDir
                              - index.jsp
                              - test.jsp
                      - package.json, bower.json, etc. (all the required files)
                  

                  基本上,index.jsp 是针对 CSS 和 JS 库和应用程序资产进行处理的,这些资产被缩小并连接成 lib.css、lib.js、app.css 和 app.js.之后,所有这些都被注入到 index.jsp 的副本中,该副本称为 test.jsp.

                  Basically, index.jsp is processed for CSS and JS library and application assets, which are minified and concatenated into lib.css, lib.js, app.css and app.js. Later all these are injected into a copy of index.jsp which is called test.jsp.

                  资产收集、连接、注入工作和磁盘上的文件修改工作出色.test.jsp中文件名的更新——没那么多...

                  The asset gathering, concatenation, injection works and file revisions on disk work splendidly. The update of file names in test.jsp- not so much...

                  任何想法或指针将不胜感激.

                  Any ideas or pointers will be appreciated.

                  推荐答案

                  您必须将 replaceInExtensions: '.jsp' 添加到 revReplace() 的选项中.

                  You have to add replaceInExtensions: '.jsp' to your options for revReplace().

                  在我查看插件代码并弄清楚之前,我遇到了这个问题一天半.我正在使用 .php 文件.文档确实说您需要这样做,但很容易错过.

                  I had this problem for a day and a half before I looked at the plugin code and figured it out. I'm using .php files. The documentation does say you need to do this but it's easily missed.

                  希望对你有帮助.

                  这篇关于无法让 gulp-rev-replace 与 gulp-useref 一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Node.js 事件流:在哪里设置 MaxListeners? 下一篇:使用 gulp-nodemon &amp; 时无法使用 Ctrl+C 停止 G

                  相关文章

                  最新文章

                  <tfoot id='ry6Fi'></tfoot>

                    <bdo id='ry6Fi'></bdo><ul id='ry6Fi'></ul>

                  1. <small id='ry6Fi'></small><noframes id='ry6Fi'>

                      <legend id='ry6Fi'><style id='ry6Fi'><dir id='ry6Fi'><q id='ry6Fi'></q></dir></style></legend>
                      <i id='ry6Fi'><tr id='ry6Fi'><dt id='ry6Fi'><q id='ry6Fi'><span id='ry6Fi'><b id='ry6Fi'><form id='ry6Fi'><ins id='ry6Fi'></ins><ul id='ry6Fi'></ul><sub id='ry6Fi'></sub></form><legend id='ry6Fi'></legend><bdo id='ry6Fi'><pre id='ry6Fi'><center id='ry6Fi'></center></pre></bdo></b><th id='ry6Fi'></th></span></q></dt></tr></i><div id='ry6Fi'><tfoot id='ry6Fi'></tfoot><dl id='ry6Fi'><fieldset id='ry6Fi'></fieldset></dl></div>