1

I have a rakefile which uses jsmin to minify the files. one thing that I need to do is that is to have a array of files which will serve as a blacklist which jsmin wouldn't include in when running the minify script.

    jsFolder = "./scripts"  
    cssFolder = "./stylesheets"
    blackList = [blackListedFile.js] #this is what i need.
    minifiedFileRootPath = "./"

    task :minify_each_file, [:type]  do |t, args|
            args.with_defaults(:type => "js")
            sourceFolder = args.type == 'js'  ? jsFolder : cssFolder
            listOfFilesToMinify = Dir.glob(sourceFolder << "/**/*." << args.type )
            listOfFilesToMinify.each do |sourceFile|
            minifiedFile = sourceFile.sub("."+ args.type,".min" + args.type) 
            puts minifiedFile
            puts sourceFile
            minifyone sourceFile, minifiedFile
        end
    end
lucapette
  • 20,564
  • 6
  • 65
  • 59
franticfrantic
  • 2,511
  • 3
  • 17
  • 14

1 Answers1

2

Change:

listOfFilesToMinify.each do |sourceFile|

to

 (listOfFilesToMinify - blackList).each do |sourceFile|

And use the following syntax for the blacklist array:

blackList = %w{foo bar}

It should work fine.

lucapette
  • 20,564
  • 6
  • 65
  • 59
  • in addition to the solution, if the files that are to be compressed are within a folder, prepend the blacklisted files with the complete path to the files, like so: `cssFolder = "./stylesheet/" blackList = ["/blacklistedFile.css", "/anotherBlackListedFile.css"].collect {|x| cssFolder + x }` – franticfrantic Feb 29 '12 at 03:45