简体   繁体   中英

Concatenate & minify directory of JS files into one JS file with Guard and 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM