[英]How to include appropriate JavaScript file's version (minified vs. raw)?
I am developing a webapp (if it matters, I use npm
and bower
). 我正在开发一个webapp(如果重要的话,我使用
npm
和bower
)。 My HTML file includes angular.js
. 我的HTML文件包含
angular.js
。 Now, I want that my production-version of the webapp uses the minified version angular.min.js
. 现在,我希望我的
angular.min.js
应用程序的生产版本使用缩小的版本angular.min.js
。
Considering I do want two versions of my webapp: 考虑到我确实需要两个版本的Webapp:
angular.js
angular.js
“原始”版本 angular.min.js
angular.min.js
“生产”版本 How is it traditionally done given that I want to maintain a single version of index.html
? 考虑到我要维护
index.html
的单个版本,传统上index.html
?
I opted for sed
invoked in a Makefile
: 我选择了在
Makefile
调用的sed
:
$(RELEASE_DIR)/index.html: $(PUBLIC_DIR)/index.html | $(RELEASE_DIR)/
$(SED) 's/\.js/.min.js/g' $< > $@
$(RELEASE_DIR)/:
$(MKDIR) --parents $@
I am accepting my own answer because it was simpler to use sed
rather than using yet another dependency (I already had a Makefile
). 我接受我自己的答案,因为使用
sed
比使用另一个依赖项更简单(我已经有了一个Makefile
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.