Grunt预先添加所有链接和路径

时间:2015-02-12 10:21:52

标签: gruntjs

我最近开始在基于AngularJS的网上商店使用Grunt,它的工作非常棒!在项目开发期间,我一直在我的本地机器上工作,使用Grunts自己的服务器进行开发。现在我们正处于部署项目的阶段,但遇到了几个hickup。

由于我们的网上商店将用作WordPress主题,因此所有路径都需要添加/wp-content/themes/ourtheme/。也就是说,需要指定此绝对路径的所有本地资源(包括LESS文件中的资源)。

最好的方法是什么?如果有任何帮助,我使用Yeoman Angular生成器创建了项目。

1 个答案:

答案 0 :(得分:1)

您可以使用grunt任务grunt-string-replace来查找和替换所有匹配的模式,例如:

'string-replace': {
  inline: {
    files: {
      'dest/': 'src/**',
    },
    options: {
      replacements: [
        // place files inline example
        {
          pattern: 'your/relative/path/',
          replacement: 'wp-content/themes/ourtheme/your/relative/path'
        }
      ]
    }
  }
}