Grunt 预先添加所有链接和路径
Grunt prepend all links and paths
我最近开始将 G运行t 用于一个基于 AngularJS 的网上商店,它运行得非常好!在项目的开发过程中,我一直在我的本地机器上工作,使用 G运行ts 自己的服务器进行开发。现在我们正处于部署项目的阶段,但是 运行 出现了一些小问题。
由于我们的网店将用作 WordPress 主题,因此所有路径都需要添加前缀 /wp-content/themes/ourtheme/
。也就是说,需要指定此绝对路径的所有本地资源(包括 LESS 文件中的资产)。
最好的方法是什么?如果有任何帮助,我使用 Yeoman Angular 生成器创建了项目。
您可以使用 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'
}
]
}
}
}
我最近开始将 G运行t 用于一个基于 AngularJS 的网上商店,它运行得非常好!在项目的开发过程中,我一直在我的本地机器上工作,使用 G运行ts 自己的服务器进行开发。现在我们正处于部署项目的阶段,但是 运行 出现了一些小问题。
由于我们的网店将用作 WordPress 主题,因此所有路径都需要添加前缀 /wp-content/themes/ourtheme/
。也就是说,需要指定此绝对路径的所有本地资源(包括 LESS 文件中的资产)。
最好的方法是什么?如果有任何帮助,我使用 Yeoman Angular 生成器创建了项目。
您可以使用 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'
}
]
}
}
}