[英]Grunt to minify and reference .min files
I need to: 我需要:
index.html
to index.uncompressed.html
index.html
复制到index.uncompressed.html
index.html
from .js
to .min.js
(ie my_jsfile.js
to my_jsfile.min.js
) 3) Minify index.html
index.html
一些引用从.js
更改为.min.js
(即,将my_jsfile.js
为my_jsfile.min.js
)3) my_jsfile.min.js
index.html
I am using Grunt. 我正在使用Grunt。
.js
file references between <!-- Start Here -->
and <!-- End here -->
from my_jsfile.js
to my_jsfile.min.js
. <!-- Start Here -->
和<!-- End here -->
从<!-- End here -->
之间的所有.js
文件引用从my_jsfile.js
为my_jsfile.min.js
。 Is this the way this type of thing is done? 这是做这种事情的方式吗?
The resource I use in this situation is grunt-processhtml , which will do exactly what you're looking for. 在这种情况下,我使用的资源是grunt-processhtml ,它将完全满足您的需求。 Check out one of my repos, steady-backbone-boilerplate , where I use this to do exactly what you're describing.
签出我的仓库之一,“ 稳定骨干”样板 ,我用它来做您所描述的。
In particular, I find this is a helpful example: 特别是,我发现这是一个有用的示例:
<!-- build:[src] js/source.min.js -->
<script data-main="js/main" src="js/vendor/require.js"></script>
<!-- /build -->
So, in development we're using the requirejs script to load all our dependencies. 因此,在开发中,我们使用requirejs脚本加载所有依赖项。 In our production
index.html
file, we're loading the source js file, which has been minified with the grunt-requirejs
module. 在生产的
index.html
文件中,我们正在加载源js文件,该文件已通过grunt-requirejs
模块grunt-requirejs
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.