Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Exclude *.min.js Files #11

Open
mslinn opened this issue Apr 21, 2015 · 5 comments
Open

How to Exclude *.min.js Files #11

mslinn opened this issue Apr 21, 2015 · 5 comments

Comments

@mslinn
Copy link

mslinn commented Apr 21, 2015

I'd like to combine multiple unminified .js files, then minify the combined file and place it in the webapps's public/js/main.min.js. I also want to ignore all WebJars JavaScript because those files are already minified.

I tried this:

pipelineStages := Seq(rjs, uglify, digest, gzip)

UglifyKeys.uglifyOps := { js =>
  Seq((js.sortBy(_._2), "main.min.js"))
}

However all .js files, including previously minified .js files, were combined, which takes forever.

I then tried adding this:

excludeFilter in uglify := GlobFilter("*.min.js")

But main.min.js now just contains:

define("main",function(){});
//# sourceMappingURL=main.js.map

Once I get this test project working, I will try it on my production app, which has dozens of JS files in various subdirectories under public/. Hopefully the solution won't require a manual listing of every .js file.

@ibanzai
Copy link

ibanzai commented Mar 11, 2016

Was there any resolution to this?

I have 3rd party Javascript files in the "public/js" directory that are already minified and, additionally, they have copyright info that must not be removed. The Javascript files I do wish to be minified are located in "app/assets/js".

I'm using Play 2.4 and have tried all the following without success:

excludeFilter in uglify := GlobFilter("*.min.js")
excludeFilter in uglify := new SimpleFileFilter(f => f.getPath.startsWith((resourceDirectory in Assets).value.getPath))
excludeFilter in uglify := new FileFilter{ def accept(f: File) = ".*min.*".r.pattern.matcher(f.getAbsolutePath).matches }
excludeFilter in (Assets, JshintKeys.jshint) := new FileFilter{ def accept(f: File) = ".*/vendor/.*".r.pattern.matcher(f.getAbsolutePath).matches }
excludeFilter in (Assets, JshintKeys.jshint) := "*.min.js"

@mslinn
Copy link
Author

mslinn commented Mar 11, 2016 via email

@iadcode
Copy link

iadcode commented Apr 19, 2016

Perhaps give the following a shot:

excludeFilter in uglify := (excludeFilter in uglify).value || GlobFilter("*.min.js")

This would prevent the default excludeFilter from being blown away.

Edit: fixed typo

@ibanzai
Copy link

ibanzai commented Apr 20, 2016

Thanks, however '+:=' generates an expression error:

error: value +:= is not a member of sbt.SettingKey[sbt.FileFilter]

@iadcode
Copy link

iadcode commented Apr 20, 2016

My bad, drop the plus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants