使用Guard和UglifyJS将JS文件的目录连接并缩小为一个JS文件(Concatenate & minify directory of JS files into one JS file wit

编程入门 行业动态 更新时间:2024-10-24 08:32:49
使用Guard和UglifyJS将JS文件的目录连接并缩小为一个JS文件(Concatenate & minify directory of JS files into one JS file with Guard and UglifyJS)

我有一个JS插件的文件夹,我想连接并使用Guard和UglifyJS缩小为一个plugins.js文件

到目前为止,这是我在Guardfile中的内容

guard 'uglify', :input => 'js-unprocessed/plugins/*.js', :output => "assets/plugins.js" do watch 'js-unprocessed/plugins/*.js' end

当我在plugins目录中保存一个JS文件但我没有在控制台中获得任何反馈并且没有更新或创建文件时,我希望会发生一些事情。

如果您认为Guard和UglifyJS不适合这项工作,请告诉我。

I have a folder of JS plugins that i would like to concatenate and minify into a plugins.js file using Guard and UglifyJS

Here's what I have in my Guardfile so far

guard 'uglify', :input => 'js-unprocessed/plugins/*.js', :output => "assets/plugins.js" do watch 'js-unprocessed/plugins/*.js' end

I'd expect something to happen when I save one of the JS files in the plugins directory but I don't get any feedback in the console and no files are updated or created.

Please let me know if you think Guard and UglifyJS are not the right tools for the job.

最满意答案

我使用了https://github.com/guard/guard-jammit 。

我需要添加一个config/assets.yml文件:

embed_assets: on javascripts: plugins: - js-unprocessed/plugins/*.js

然后将其添加到我的Guardfile

guard :jammit, :output_folder => "assets/" do watch(%r{^js-unprocessed/plugins/(.*)\.js$}) end

I used https://github.com/guard/guard-jammit which did the trick.

I needed to add a config/assets.yml file with this:

embed_assets: on javascripts: plugins: - js-unprocessed/plugins/*.js

and then added this to my Guardfile

guard :jammit, :output_folder => "assets/" do watch(%r{^js-unprocessed/plugins/(.*)\.js$}) end

更多推荐

本文发布于:2023-07-28 18:45:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1307992.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   目录   UglifyJS   JS   Guard

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!