谁可以在grunt- wiredp生成的URL's上添加前缀和后缀?

Who can i append a prefix and a suffix to the URL's generated by grunt-wiredep?

本文关键字:添加 加前缀 后缀 URL grunt- wiredp      更新时间:2023-09-26

我正在尝试使用grunt- wiredp来修改我的spring-boot项目中的源代码。

使用bower可以通过下拉JS/CSS和依赖项来工作,并且grunt-wiredep将更新源代码,但是由于我使用thymeleaf的方式,我需要用@{URL_GOES_HERE}包围URL。

这可能吗?grunt- wiredp有前缀/后缀选项吗?(到目前为止我还没有找到这个)。

电流输出:

<!-- bower-js:start -->
    <script src="bower_components'bootstrap-colorpicker'js'bootstrap-colorpicker.js">
    </script>
<!-- bower-js:end -->
所需输出:

<!-- bower-js:start -->
    <script src="@{'bower_components'bootstrap-colorpicker'js'bootstrap-colorpicker.js}">
    </script>
<!-- bower-js:end -->

grunt-wiredep可以使用原始wiredep提供的任何配置选项。

在上面的链接中,你可以看到输出格式也可以配置,github自述文件给出了一个向脚本标签附加随机类的示例:

fileTypes: {
fileExtension: {
  block: /match the beginning-to-end of a bower block in this type of file/,
  detect: {
    typeOfBowerFile: /match the way this type of file is included/
  },
  replace: {
    typeOfBowerFile: '<format for this {{filePath}} to be injected>',
    anotherTypeOfBowerFile: function (filePath) {
      return '<script class="random-' + Math.random() + '" src="' + filePath + '"></script>';
    }
  }
}, //...

例如,你可以像这样覆盖默认的HTML文件扩展配置块:

html: {
  block: /(([ 't]*)<!--'s*bower:*('S*)'s*-->)('n|'r|.)*?(<!--'s*endbower's*-->)/gi,
  detect: {
    js: /<script.*src=['"]([^'"]+)/gi
  },
  replace: {
    js: '<script src="@{''{{filePath}}}"></script>'
  }
},