Angular 使用grunt不更新引用进行缓存破坏
我使用npmAngular 使用grunt不更新引用进行缓存破坏,angular,caching,npm,gruntjs,browser-cache,Angular,Caching,Npm,Gruntjs,Browser Cache,我使用npmgrunt cache-bust来破坏静态文件的缓存 我有以下文件夹结构 - app - scripts - app.js - app.config.js - controllers - controller1.js - controller12.js - index.html - Gruntfile.js 在gruntfile.js中,我添加了基本配置
grunt cache-bust
来破坏静态文件的缓存
我有以下文件夹结构
- app
- scripts
- app.js
- app.config.js
- controllers
- controller1.js
- controller12.js
- index.html
- Gruntfile.js
在gruntfile.js中,我添加了基本配置
cacheBust: {
taskName: {
options: {
assets: ['dist/scripts/**'],
jsonOutput: true,
createCopies: true,
deleteOriginals: false
},
src: ['dist/index.html',]
}
}
它会破坏src中给定的文件,但不会替换index.html中的引用
我缺少什么吗?我遇到了类似的问题,这是因为我在index.html中导入的路径没有
dist/scripts/**
格式,而是scripts/**
。我通过为我想要被破坏的文件指定baseDir和为需要更新其引用的文件指定cwd解决了这个问题:
cacheBust: {
taskName: {
options:{
baseDir:'<%= somedir %>/',
assets:['**.js'],
deleteOriginals: true
},
files: [{
expand: true,
cwd: '<%= somedir %>/',
src: ['index.html']
}]
}
}
cacheBust:{
任务名称:{
选项:{
baseDir:“/”,
资产:['**.js'],
真的吗
},
档案:[{
是的,
cwd:“/”,
src:['index.html']
}]
}
}
我遇到了类似的问题,这是因为我在index.html中导入的路径不是dist/scripts/**
,而是scripts/**
。我通过为我想要被破坏的文件指定baseDir和为需要更新其引用的文件指定cwd解决了这个问题:
cacheBust: {
taskName: {
options:{
baseDir:'<%= somedir %>/',
assets:['**.js'],
deleteOriginals: true
},
files: [{
expand: true,
cwd: '<%= somedir %>/',
src: ['index.html']
}]
}
}
cacheBust:{
任务名称:{
选项:{
baseDir:“/”,
资产:['**.js'],
真的吗
},
档案:[{
是的,
cwd:“/”,
src:['index.html']
}]
}
}