Node.js   发布时间:2022-04-24  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了gruntjs – grunt usemin不会影响html文件(index.html)大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个使用usemin的grunt脚本,但奇怪的是index.html文件完全不受usemin的影响!这意味着我的文件仍然拥有所有

<!-- build:css styles/main.css -->
    <link rel="stylesheet" href="styles/style.css">
    <link rel="stylesheet" href="styles/bs-growl-notifications.css">
    <!-- endbuild -->

日志中最奇怪的部分就是这个(然它找到了块,但它什么也没做 – 看完全日志):

Processing as HTML - dist/index.html
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 the 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

这是一个完整的日志:

Running "clean:dist" (clean) task
Cleaning .tmp...oK
Cleaning dist/index.html...oK
Cleaning dist/scripts...oK
Cleaning dist/styles...oK

Running "replace:dist" (replacE) task
replace app/index.html -> .tmp/index.html

Running "useminPrepare:html" (useminPreparE) task
Going through .tmp/index.html to update the config
Looking for build script HTML comment blocks

Found a block:
        <!-- build:css styles/main.css -->
        <link rel="stylesheet" href="styles/style.css">
        <link rel="stylesheet" href="styles/bs-growl-notifications.css">
        <!-- endbuild -->
updating config with the following assets:
    - .tmp\styles\style.css
    - .tmp\styles\bs-growl-notifications.css

Found a block:
        <!-- build:js(app) scripts/components.js -->
        <script src="bower_components/jquery/dist/jquery.js"></script>
        <script src="bower_components/handlebars/handlebars.runtime.js"></script
>
        <script src="bower_components/ember/ember.prod.js"></script>
        <script src="bower_components/ember-data/ember-data.prod.js"></script>
        <!-- endbuild -->
updating config with the following assets:
    - app\bower_components\jquery\dist\jquery.js
    - app\bower_components\handlebars\handlebars.runtime.js
    - app\bower_components\ember\ember.prod.js
    - app\bower_components\ember-data\ember-data.prod.js

Found a block:
        <!-- build:js(.tmp) scripts/templates.js -->
        <script src="scripts/compiled-templates.js"></script>
        <!-- endbuild -->
updating config with the following assets:
    - .tmp\scripts\compiled-templates.js

Found a block:
        <!-- build:js(.tmp) scripts/main.js -->
        <script src="scripts/combined-scripts.js"></script>
        <!-- endbuild -->
updating config with the following assets:
    - .tmp\scripts\combined-scripts.js

Found a block:
        <!-- build:js scripts/plugins.js -->
        <script src="bower_components/ember-addons.bs_for_ember/dist/js/bs-core.
max.js"></script>
        <script src="bower_components/ember-addons.bs_for_ember/dist/js/bs-alert
.max.js"></script>
        <script src="bower_components/ember-addons.bs_for_ember/dist/js/bs-badge
.max.js"></script>
        <script src="bower_components/ember-addons.bs_for_ember/dist/js/bs-basic
.max.js"></script>
        <script src="bower_components/ember-addons.bs_for_ember/dist/js/bs-butto
n.max.js"></script>
        <script src="bower_components/ember-addons.bs_for_ember/dist/js/bs-growl
-notifications.max.js"></script>
        <script src="bower_components/ember-addons.bs_for_ember/dist/js/bs-items
-action-bar.max.js"></script>
        <script src="bower_components/ember-addons.bs_for_ember/dist/js/bs-label
.max.js"></script>
        <script src="bower_components/ember-addons.bs_for_ember/dist/js/bs-list-
group.max.js"></script>
        <script src="bower_components/ember-addons.bs_for_ember/dist/js/bs-modal
.max.js"></script>
        <script src="bower_components/ember-addons.bs_for_ember/dist/js/bs-nav.m
ax.js"></script>
        <script src="bower_components/ember-addons.bs_for_ember/dist/js/bs-notif
ications.max.js"></script>
        <script src="bower_components/ember-addons.bs_for_ember/dist/js/bs-progr
essbar.max.js"></script>
        <script src="bower_components/ember-addons.bs_for_ember/dist/js/bs-wizar
d.max.js"></script>
        <!-- endbuild -->
updating config with the following assets:
    - .tmp\bower_components\ember-addons.bs_for_ember\dist\js\bs-core.max.js
    - .tmp\bower_components\ember-addons.bs_for_ember\dist\js\bs-alert.max.js
    - .tmp\bower_components\ember-addons.bs_for_ember\dist\js\bs-badge.max.js
    - .tmp\bower_components\ember-addons.bs_for_ember\dist\js\bs-basic.max.js
    - .tmp\bower_components\ember-addons.bs_for_ember\dist\js\bs-button.max.js
    - .tmp\bower_components\ember-addons.bs_for_ember\dist\js\bs-growl-notificat
ions.max.js
    - .tmp\bower_components\ember-addons.bs_for_ember\dist\js\bs-items-action-ba
r.max.js
    - .tmp\bower_components\ember-addons.bs_for_ember\dist\js\bs-label.max.js
    - .tmp\bower_components\ember-addons.bs_for_ember\dist\js\bs-list-group.max.
js
    - .tmp\bower_components\ember-addons.bs_for_ember\dist\js\bs-modal.max.js
    - .tmp\bower_components\ember-addons.bs_for_ember\dist\js\bs-nav.max.js
    - .tmp\bower_components\ember-addons.bs_for_ember\dist\js\bs-notifications.m
ax.js
    - .tmp\bower_components\ember-addons.bs_for_ember\dist\js\bs-progressbar.max
.js
    - .tmp\bower_components\ember-addons.bs_for_ember\dist\js\bs-wizard.max.js

Configuration is Now:

  cssmin:
  { dist:
   { files:
      { '<%= yeoman.dist %>/styles/main.css':
         [ '.tmp/styles/{,*/}*.css','app/styles/{,*/}*.css' ] } },'dist\\styles\\main.css': 'dist\\styles\\main.css' }

  concat:
  { 'dist\\styles\\main.css':
   [ '.tmp\\styles\\style.css','.tmp\\styles\\bs-growl-notifications.css' ],'dist\\scripts\\components.js':
   [ 'app\\bower_components\\jquery\\dist\\jquery.js','app\\bower_components\\handlebars\\handlebars.runtime.js','app\\bower_components\\ember\\ember.prod.js','app\\bower_components\\ember-data\\ember-data.prod.js' ],'dist\\scripts\\templates.js': [ '.tmp\\scripts\\compiled-templates.js' ],'dist\\scripts\\main.js': [ '.tmp\\scripts\\combined-scripts.js' ],'dist\\scripts\\plugins.js':
   [ '.tmp\\bower_components\\ember-addons.bs_for_ember\\dist\\js\\bs-core.max.j
s','.tmp\\bower_components\\ember-addons.bs_for_ember\\dist\\js\\bs-alert.max.
js','.tmp\\bower_components\\ember-addons.bs_for_ember\\dist\\js\\bs-badge.max.
js','.tmp\\bower_components\\ember-addons.bs_for_ember\\dist\\js\\bs-basic.max.
js','.tmp\\bower_components\\ember-addons.bs_for_ember\\dist\\js\\bs-button.max
.js','.tmp\\bower_components\\ember-addons.bs_for_ember\\dist\\js\\bs-growl-noti
fications.max.js','.tmp\\bower_components\\ember-addons.bs_for_ember\\dist\\js\\bs-items-acti
on-bar.max.js','.tmp\\bower_components\\ember-addons.bs_for_ember\\dist\\js\\bs-label.max.
js','.tmp\\bower_components\\ember-addons.bs_for_ember\\dist\\js\\bs-list-group
.max.js','.tmp\\bower_components\\ember-addons.bs_for_ember\\dist\\js\\bs-modal.max.
js','.tmp\\bower_components\\ember-addons.bs_for_ember\\dist\\js\\bs-nav.max.js
','.tmp\\bower_components\\ember-addons.bs_for_ember\\dist\\js\\bs-notificati
ons.max.js','.tmp\\bower_components\\ember-addons.bs_for_ember\\dist\\js\\bs-progressba
r.max.js','.tmp\\bower_components\\ember-addons.bs_for_ember\\dist\\js\\bs-wizard.max
.js' ] }

  uglify:
  { 'dist\\scripts\\components.js': 'dist\\scripts\\components.js','dist\\scripts\\templates.js': 'dist\\scripts\\templates.js','dist\\scripts\\main.js': 'dist\\scripts\\main.js','dist\\scripts\\plugins.js': 'dist\\scripts\\plugins.js' }

  requirejs:
  {}

Running "concurrent:dist" (concurrent) task

Running "imagemin:dist" (imagemin) task
Minified 0 images (saved 0 B)

Done,without errors.

Running "svgmin:dist" (svgmin) task

Done,without errors.

Running "htmlmin:dist" (htmlmin) task
File dist/index.html created.

Done,without errors.

Running "emberTemplates:dist" (emberTemplates) task
File ".tmp/scripts/compiled-templates.js" created.

Done,without errors.

Running "compass:dist" (compass) task
directory .tmp/styles/
       create .tmp/styles/style.css (2.682s)
    Compilation took 2.686s

Done,without errors.

Running "neuter:app" (neuter) task

Running "concat:dist\styles\main.css" (concat) task
File "dist\styles\main.css" created.

Running "concat:dist\scripts\components.js" (concat) task
File "dist\scripts\components.js" created.

Running "concat:dist\scripts\templates.js" (concat) task
File "dist\scripts\templates.js" created.

Running "concat:dist\scripts\main.js" (concat) task
File "dist\scripts\main.js" created.

Running "concat:dist\scripts\plugins.js" (concat) task
File "dist\scripts\plugins.js" created.

Running "cssmin:dist" (cssmin) task
File dist/styles/main.css created.

Running "cssmin:dist\styles\main.css" (cssmin) task
File dist\styles\main.css created.

Running "uglify:dist\scripts\components.js" (uglify) task
File "dist\scripts\components.js" created.

Running "uglify:dist\scripts\templates.js" (uglify) task
File "dist\scripts\templates.js" created.

Running "uglify:dist\scripts\main.js" (uglify) task
File "dist\scripts\main.js" created.

Running "uglify:dist\scripts\plugins.js" (uglify) task
File "dist\scripts\plugins.js" created.

Running "copy:fonts" (copy) task
Copied 9 files

Running "copy:dist" (copy) task
Copied 9 files

Running "rev:dist" (rev) task
dist/scripts/components.js >> bb1ae45b.components.js
dist/scripts/main.js >> 69c75525.main.js
dist/scripts/plugins.js >> d41d8cd9.plugins.js
dist/scripts/templates.js >> e425eb4f.templates.js
dist/styles/main.css >> 5baff5b5.main.css
dist/styles/fonts/FontAwesome.otf >> 543846b5.FontAwesome.otf
dist/styles/fonts/fontawesome-webfont.eot >> 906d33f8.fontawesome-webfont.eot
dist/styles/fonts/fontawesome-webfont.svg >> 776d58f4.fontawesome-webfont.svg
dist/styles/fonts/fontawesome-webfont.ttf >> 370c636d.fontawesome-webfont.ttf
dist/styles/fonts/fontawesome-webfont.woff >> 3f97f72d.fontawesome-webfont.woff
dist/styles/fonts/glyphicons-halflings-regular.eot >> e56f39cb.glyphicons-halfli
ngs-regular.eot
dist/styles/fonts/glyphicons-halflings-regular.svg >> 32941d63.glyphicons-halfli
ngs-regular.svg
dist/styles/fonts/glyphicons-halflings-regular.ttf >> 38e827a0.glyphicons-halfli
ngs-regular.ttf
dist/styles/fonts/glyphicons-halflings-regular.woff >> deae260a.glyphicons-halfl
ings-regular.woff

Running "usemin:html" (usemin) task

Processing as HTML - dist/index.html
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 the 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

Running "usemin:css" (usemin) task

Processing as CSS - dist/styles/5baff5b5.main.css
update the CSS with new img filenames
url(../styles/fonts/glyphicons-halflings-regular.eot) changed to url(../styles/f
onts/e56f39cb.glyphicons-halflings-regular.eot)
url(../styles/fonts/glyphicons-halflings-regular.eot?#iefiX) changed to url(../s
tyles/fonts/e56f39cb.glyphicons-halflings-regular.eot?#iefiX)
url(../styles/fonts/glyphicons-halflings-regular.woff) changed to url(../styles/
fonts/deae260a.glyphicons-halflings-regular.woff)
url(../styles/fonts/glyphicons-halflings-regular.ttf) changed to url(../styles/f
onts/38e827a0.glyphicons-halflings-regular.ttf)
url(../styles/fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular
) changed to url(../styles/fonts/32941d63.glyphicons-halflings-regular.svg#glyph
icons_halflingsregular)

Done,without errors.

解决方法

好的,这是最愚蠢的事情
似乎usemin无法处理Windows新行,所以它只是无声地无法更新html文件
我已将所有新行更改为UNIX新行,并且它有效…

很难发现这个bug

本图文内容来源于网友网络收集整理提供,作为学习参使用,版权属于原作者。

大佬总结

以上是大佬教程为你收集整理的gruntjs – grunt usemin不会影响html文件(index.html)全部内容,希望文章能够帮你解决gruntjs – grunt usemin不会影响html文件(index.html)所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。