![](/img/trans.png)
[英]Angular “Unknown Provider” error after minification with Grunt Build in Yeoman app
[英]Disable minification in Grunt (Yeoman)
我最近開始通過Yeoman使用GruntJS,我喜歡Javascript縮小的想法,但它在開發過程中遇到了困難。 我試圖在Gruntfile中以不同的組合禁用uglify,usemin等,但是一切似乎都依賴於另一件事並打破了這個過程。 有沒有簡單的方法來禁用縮小? 我正在使用Yeoman提供的最新版本的Grunt,我發現舊的解決方案具有與使用Yeoman的usd不同的Gruntfile設置。
這是我的Gruntfile:
// Reads HTML for usemin blocks to enable smart builds that automatically
// concat, minify and revision files. Creates configurations in memory so
// additional tasks can operate on them
useminPrepare: {
options: {
dest: '<%= config.dist %>'
},
html: '<%= config.app %>/index.html'
},
我需要調整usemin flow:
選項:
根據yeoman grunt usemin的精細手冊 ,默認flow:
是
{ steps: { js: ['concat', 'uglify'], css: ['concat', 'cssmin'] }, post: {} }
這里是我如何修改要點我喲web應用Gruntfile.js
刪除uglify
從流。
這個評論塊在你的Gruntfile中:
// By default, your `index.html`'s <!-- Usemin block --> will take care
// of minification. These next options are pre-configured if you do not
// wish to use the Usemin blocks.
基於此,從index.html文件中刪除<!-- Usemin block -->
應該可以防止useminPrepare
grunt任務縮小你的javascript。
此外,您可以編輯uglify
任務以創建新文件,以通過將.min
添加到文件擴展名來覆蓋您的dev文件:
uglify: {
dist: {
files: {
'<%= config.dist %>/scripts/scripts.js': [
'<%= config.dist %>/scripts/scripts.min.js'
]
}
}
},
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.