Gruntjs 阻止grunt更改字体上的名称
所以我现在的情况是,我在我的Gruntjs 阻止grunt更改字体上的名称,gruntjs,yeoman,grunt-usemin,Gruntjs,Yeoman,Grunt Usemin,所以我现在的情况是,我在我的Yeoman项目中添加了一种字体。然而,有一个小问题。每当我运行grunt build时,我的字体的文件名都会更改,但在我的CSS中不会更改,从而导致它无法工作 我怎样才能解决这个问题。我知道我必须查看我的Gruntfile.js,但我不知道该去哪里查看 我已经试过了: // Performs rewrites based on rev and the useminPrepare configuration usemin: { html: ['<%= yeo
Yeoman
项目中添加了一种字体。然而,有一个小问题。每当我运行grunt build
时,我的字体的文件名都会更改,但在我的CSS
中不会更改,从而导致它无法工作
我怎样才能解决这个问题。我知道我必须查看我的Gruntfile.js
,但我不知道该去哪里查看
我已经试过了:
// Performs rewrites based on rev and the useminPrepare configuration
usemin: {
html: ['<%= yeoman.dist %>/public/{,*/}*.html'],
css: ['<%= yeoman.dist %>/public/{,*/}*.css'],
js: ['<%= yeoman.dist %>/public/{,*/}*.js'],
options: {
assetsDirs: [
'<%= yeoman.dist %>/public',
'<%= yeoman.dist %>/public/assets/images',
'<%= yeoman.dist %>/public/assets/fonts'
],
// This is so we update image references in our ng-templates
patterns: {
js: [
[/(assets\/images\/.*?\.(?:gif|jpeg|jpg|png|webp|svg))/gm, 'Update the JS to reference our revved images']
],
css: [
[/(assets\/images\/.*?\.(?:gif|jpeg|jpg|png|webp|svg))/gm, 'Update the CSS to reference our revved images']
]
}
}
},
之后
根据->
{
usemin:{
选项:{
资产目录:[
'',
“/图像”,
“/风格”
]
},
html:['/{,*/}*.html'],
css:['/styles/{,*/}*.css']
}
}
摆脱字体应该有助于我猜?实际解决方案强>
感谢费尔托的链接,我找到了一个解决方案。这有点像他建议的,只是不得不在其他地方更改代码
这就是我的解决方案:
// Renames files for browser caching purposes
rev: {
dist: {
files: {
src: [
'<%= yeoman.dist %>/public/{,*/}*.js',
'<%= yeoman.dist %>/public/{,*/}*.css',
//'<%= yeoman.dist %>/public/assets/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
//'<%= yeoman.dist %>/public/assets/fonts/*'
]
}
}
},
// Performs rewrites based on rev and the useminPrepare configuration
usemin: {
html: ['<%= yeoman.dist %>/public/{,*/}*.html'],
css: ['<%= yeoman.dist %>/public/{,*/}*.css'],
js: ['<%= yeoman.dist %>/public/{,*/}*.js'],
options: {
assetsDirs: [
'<%= yeoman.dist %>/public',
'<%= yeoman.dist %>/public/assets/images'
],
// This is so we update image references in our ng-templates
patterns: {
js: [
[/(assets\/images\/.*?\.(?:gif|jpeg|jpg|png|webp|svg))/gm, 'Update the JS to reference our revved images']
]
}
}
},
//重命名文件以用于浏览器缓存
修订版:{
地区:{
档案:{
src:[
“/public/{,*/}*.js”,
“/public/{,*/}*.css”,
//“/public/assets/images/{,*/}{png,jpg,jpeg,gif,webp,svg}”,
//“/public/assets/font/*”
]
}
}
},
//根据rev和useminPrepare配置执行重写
usemin:{
html:['/public/{,*/}*.html'],
css:['/public/{,*/}*.css'],
js:['/public/{,*/}*.js'],
选项:{
资产目录:[
“/公众”,
“/public/assets/images”
],
//这就是我们在ng模板中更新图像引用的原因
模式:{
js:[
[/(assets\/images\/.*。(?:gif | jpeg | jpg | png | webp | svg))/gm,“更新JS以引用我们的快速图像”]
]
}
}
},
您能否显示文件名的更改情况?并根据->//基于rev和useminPrepare配置执行重写usemin:{options:{assetsDirs:['''''/images','/styles']},html:['/{,/}.html'],css:['/styles/{,/}.css']},所以,也许只要去掉字体就可以了,这才是正确的答案。但是帮我找到了解决办法谢谢你的投票!是的,我确信这不是确切的解决方案,但会有所帮助。:)
20118b60.ITCEDSCR.TTF
{
usemin: {
options: {
assetsDirs: [
'<%%= config.dist %>',
'<%%= config.dist %>/images',
'<%%= config.dist %>/styles'
]
},
html: ['<%%= config.dist %>/{,*/}*.html'],
css: ['<%%= config.dist %>/styles/{,*/}*.css']
}
}
// Renames files for browser caching purposes
rev: {
dist: {
files: {
src: [
'<%= yeoman.dist %>/public/{,*/}*.js',
'<%= yeoman.dist %>/public/{,*/}*.css',
//'<%= yeoman.dist %>/public/assets/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
//'<%= yeoman.dist %>/public/assets/fonts/*'
]
}
}
},
// Performs rewrites based on rev and the useminPrepare configuration
usemin: {
html: ['<%= yeoman.dist %>/public/{,*/}*.html'],
css: ['<%= yeoman.dist %>/public/{,*/}*.css'],
js: ['<%= yeoman.dist %>/public/{,*/}*.js'],
options: {
assetsDirs: [
'<%= yeoman.dist %>/public',
'<%= yeoman.dist %>/public/assets/images'
],
// This is so we update image references in our ng-templates
patterns: {
js: [
[/(assets\/images\/.*?\.(?:gif|jpeg|jpg|png|webp|svg))/gm, 'Update the JS to reference our revved images']
]
}
}
},