I recently started using GruntJS through Yeoman and I like the idea of Javascript minification, but it presents difficulties during development. I tried to disable uglify,usemin, etc in different binations in the Gruntfile but everything seems to be dependent on another thing and breaks the process. Is there a simple way to disable minification? I am using the latest versionof Grunt offered by Yeoman to date, I found that older solutions have a different Gruntfile setup than that usd with Yeoman.
Here is my 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'
},
.js
I recently started using GruntJS through Yeoman and I like the idea of Javascript minification, but it presents difficulties during development. I tried to disable uglify,usemin, etc in different binations in the Gruntfile but everything seems to be dependent on another thing and breaks the process. Is there a simple way to disable minification? I am using the latest versionof Grunt offered by Yeoman to date, I found that older solutions have a different Gruntfile setup than that usd with Yeoman.
Here is my 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'
},
http://hastebin./gicabukojo.js
Share Improve this question edited Nov 18, 2015 at 20:08 msanford 12.3k13 gold badges71 silver badges98 bronze badges asked Nov 15, 2015 at 20:25 frazrasfrazras 6,5385 gold badges32 silver badges40 bronze badges 10- You can change the configuration of grunt-contrib-minify to do what you want, and keep the task enabled. I don't know yeoman, but there's still a Gruntfile.js, right? – Kenney Commented Nov 15, 2015 at 20:30
-
yes there is still a gruntfile but i see this in ments for uglify ` //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.// uglify: {...` see added gruntfile – frazras Commented Nov 15, 2015 at 20:35 - I don't understand the reason for the downvote, please ment if you feel I didn't describe the question properly – frazras Commented Nov 15, 2015 at 20:44
- 1 Please include the relevant parts of the grunt file in your question - the question should be self contained. – Ryley Commented Nov 18, 2015 at 20:01
-
1
Read Ryley's ment to see why you were downvoted. Has nothing to do with what you're asking--it's how you're asking it. Also, I looked at the gruntfile you posted. Why can't you just remove the
<!-- Usemin block -->
ments in your HTML file? – jperezov Commented Nov 18, 2015 at 20:08
2 Answers
Reset to default 3I needed to tweak the usemin flow:
option:
as per yeoman grunt usemin's fine manual, the default flow:
is
{ steps: { js: ['concat', 'uglify'], css: ['concat', 'cssmin'] }, post: {} }
Here is a gist of how I modified my yo webapp Gruntfile.js
to remove uglify
from the flow.
This ment block was in your 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.
Based on this, removing the <!-- Usemin block -->
from your index.html file should prevent the useminPrepare
grunt task from minifying your javascript.
Additionally, you can edit your uglify
task to create new files to not overwrite your dev files by adding .min
to the file extension:
uglify: {
dist: {
files: {
'<%= config.dist %>/scripts/scripts.js': [
'<%= config.dist %>/scripts/scripts.min.js'
]
}
}
},
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745257968a4619070.html
评论列表(0条)