我可以看到 css 和 js 文件正确地连接、修改并复制到正确的文件夹中。但是,最后一步是用用户名替换 html 文件中的块和图像,但由于某种原因无法正常工作。css 文件中的图像引用确实被替换了。
Gruntfile.js:
useminPrepare: {
html: '<%= yeoman.app %>/index.html',
options: {
dest: '<%= yeoman.dist %>'
}
},
// Performs rewrites based on rev and the useminPrepare configuration
usemin: {
css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
html: ['<%= yeoman.dist %>/{,*/}*.html'],
options: {
assetsDirs: ['<%= yeoman.dist %>/images', '<%= yeoman.dist %>/styles', '<%= yeoman.dist %>/scripts']
}
},
在 HTML 中我有:
<!-- build:css styles/main.css -->
<link rel="stylesheet" href="Styles/main.css">
<link rel="stylesheet" href="Shared/Styles/default.css">
<link rel="stylesheet" href="Shared/Styles/default.date.css">
<link rel="stylesheet" href="Shared/Styles/default.time.css">
<!-- endbuild -->
构建时的输出说:
[1mProcessing as HTML - dist/index.html[22m
Update the HTML to reference our concat/min/revved script files
Update the HTML with the new css filenames
Update the HTML with the new img filenames
Update the HTML with data-main tags
Update the HTML with data-* tags
Update the HTML with background imgs, case there is some inline style
Update the HTML with anchors images
Update the HTML with reference in input
dist 中的文件结构:
– dist
|– index.html
|– styles
|– 146eba12.main.css
|– scripts
|– ...
|– images
|– ...
这一直让我发疯,我不知道为什么。任何帮助将不胜感激。
更新:在进一步的开发中,我不知道为什么,现在 html 中的块被替换为指向连接文件的一行,但它不会预先添加在 revving 期间添加的哈希。所以它:
<link rel="stylesheet" href="styles/main.css"/>
而不是:
<link rel="stylesheet" href="styles/b64b6f59.main.css"/>