约曼Angular.js / EX press.js - 格朗特覆盖每个手动重启的index.html [英] Yeoman Angular.js/Express.js - Grunt overwrites index.html on each manual restart

查看:194
本文介绍了约曼Angular.js / EX press.js - 格朗特覆盖每个手动重启的index.html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的使用约曼和我使用它的Bootstrap一个Angular.js和Ex press.js。该Gruntfile.js似乎势不可挡。我有几个问题:


  1. 每次我restrart与'咕噜启动网络服务器我
    应用程序/ index.html文件被覆盖。这是一场噩梦......怎么能
    我停止?

  2. 添加一个普通的CSS目录...应用程序/ CSS。我怎么能够
        获得咕噜检测文件的变化并重新载入浏览器?一世
        试图CSS / * CSS。,但没有运气:

     手表:{
        文件:
          '<%= yeoman.app%GT; / {* /} * HTML。,
          CSS / *。CSS,
          .TMP /风格/ {* /} *。CSS,
          '<%= yeoman.app%方式> /图像/ {* /} * {PNG,JPG,JPEG,GIF,WEBP,SVG}
        ]
      }



解决方案

咕噜在应用程序中树的根文件夹中运行,所以虽然你在正确的轨道修改表对象上,您将需要添加&LT;%= yeoman.app%GT; / 你的 CSS / * CSS 所以看起来在正确的文件夹之前。 yeoman.app <​​/ code>其实只是位置朝向文件顶部的变量。

要测试您的应用,使用咕噜服务,并且不应该覆盖您的索引文件。否则,发现在部分你的 Gruntfile.js ,其中定义 grunt.registerTask('服务',找到 grunt.task.run ,并尝试注释掉每个任务并重新运行咕噜服务来发现被覆盖的罪魁祸首索引文件。

I am new at using Yeoman and I am using it for bootstraping a Angular.js and Express.js. The Gruntfile.js seems overwhelming. I have a couple of issues:

  1. Everytime I restrart the webserver with 'grunt start' my app/index.html file gets overwritten. This is a nightmare...how can I stop this?
  2. I add a normal css directory... app/css. How can I get grunt to detect file changes in it and reload the browser? I tried 'css/*.css' but no luck:

    watch: {
        files: [
          '<%= yeoman.app %>/{,*/}*.html',
          'css/*.css',
          '.tmp/styles/{,*/}*.css',
          '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ]   
      }'
    

解决方案

Grunt is running in the root folder of your application tree, so although you were on the right track modifying the watch object, you will need to add <%= yeoman.app %>/ before your css/*.css so it will look in the correct folder. yeoman.app is actually just a variable located towards the top of the file.

To test your app, use grunt serve and that shouldn't overwrite your index file. Otherwise, find the section in your Gruntfile.js where grunt.registerTask('serve' is defined, locate the grunt.task.run and try commenting out each task and re-running grunt serve to find the culprit that is overwriting your index file.

这篇关于约曼Angular.js / EX press.js - 格朗特覆盖每个手动重启的index.html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆