简体   繁体   English

Yeoman生成器角度构建任务无法正常工作

[英]Yeoman generator-angular build task not working properly

Update: I was able to solve the issue. 更新:我能够解决问题。 One of the third part scripts I was including was missing a semicolon, thereby breaking the closure. 我包括的第三部分脚本之一缺少分号,从而破坏了闭包。 When the minified version was being used, the generator didn't know where the block ended and new blocks began. 使用缩小版本时,生成器不知道该块在哪里结束,而新块开始。 The grunt build process works fine as is now, without modification. grunt构建过程现在可以正常工作,无需修改。

I've got an angular app that I built with the generator-angular yeoman generator and it works wonderfully in the local "grunt serve" state. 我有一个使用生成器-角度yeoman生成器构建的角度应用程序,它在本地“咕serve服务”状态下表现出色。 When I run "grunt build," however, the built version doesn't work properly. 但是,当我运行“ grunt build”时,生成的版本无法正常工作。 I'm using the standard Gruntfile that comes with the generator. 我正在使用生成器随附的标准Gruntfile。

The only different between the grunt serve and the grunt build tasks are the minification, concatenation and uglification of files. grunt servegrunt build任务之间的唯一区别是文件的缩小,串联和丑化。 You'd think it would simply concat and minify the files in the same order it loads them in the development build, but it looks like things are being loaded in a different order—throwing a app.init() is not a function error—which tells me the app module isn't loaded before that section. 您可能会以将文件加载到开发版本中的相同顺序简单地合并并缩小文件,但是看起来事情以不同的顺序加载app.init() is not a function抛出app.init() is not a function错误)告诉我该部分之前未加载应用模块。

Is there something that needs to be done to the default build task to fix this issue? 要解决此问题,默认构建任务是否需要做些什么?

I'm not sure what the problem is, but I think that can be the minification process, there are several ways of writing a controller and some of them have problems at the time of the minification. 我不确定是什么问题,但是我认为这可能是缩小过程,有几种编写控制器的方法,其中有些在缩小时有问题。
If the problem is the minification you could check these pages. 如果问题是缩小,则可以检查这些页面。

  1. AnularJs - A note on minification AnularJs-有关缩小的说明
  2. Best Practice of Minification StackOverflow 缩小StackOverflow的最佳做法
  3. Example about minifying AngularJs Controllers 最小化AngularJs控制器的示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM