Grails Asset Pipeline - minifyJs set to true not working - grails

I used grails asset pipeline plugin to minify my application (I don't have any problem when running grails run-app) the problem arises when I'm going to generate a war file to deploy into tomcat server.
Currently using ':asset-pipeline:1.9.9'
currently My Config.groovy has this setup
grails.assets.minifyJs = true
grails.assets.minifyCss = true
grails.assets.bundle = true
The Particular problem here is when I'm going to set minifyJs = true
when I'm going to set minifyJs = false there's no error but my war file are not going to work when deployed to tomcat server.
| Error 2016-03-13 01:50:16,590 [main] ERROR pipeline.AssetCompiler - Uglify JS Exception
Message: [object Object] (/application/target/work/resources/uglifyjs/lib/parse-js.js#273)
Line | Method ->> 273 | _c_js_error_13 in org.mozilla.javascript.gen._application_target_work_resources_uglifyjs_lib_parse_js_js_2
I don't know whats going on or I missed something?

Immediately above the error message lines you quoted should be lines like this:
| Processing File 851 of 888 - jquery/src/intro.js
| Uglifying File 851 of 888 - jquery/src/intro
Whatever javascript file that is mentioned there probably has either some syntax error, or possibly weird non-ascii characters that were introduced because of file encoding issues or something.

Related

Grails: excluding a JS file from minification

I read tons of documentation on asset-pipeline Grails plugin, but found no definite answers and I can not exclude a single stupid JS file from being minified.
Grails is in ver. 3.3.6 and assetPipelineVersion 2.14.1.
Goal:
Stop minifying grails-app/assets/javascripts/json-tree/json-tree.js.
What I tried:
I changed the assets block in build.gradle:
assets {
minifyJs = true
minifyCss = true
includes = []
excludes = [ '**/json-tree.js' ] // tried also with 'json-tree/json-tree.js'
}
I also added a section to my application.yml:
grails:
assets:
excludes: ['json-tree/*.js'] # also tried with **
Problem: the file still gets minified.
How can I solve the problem?
Also, how the assets pipeline should be configured: per build.gradle or application.yml or both?
Please try with following :
grails.assets.minifyOptions.excludes = ["json-tree/json-tree.js"]
To exclude single file you can try above otherwise you can exclude whole folder from minify
grails.assets.minifyOptions.excludes = ["json-tree/*.js"]
For more information you check documentation
Hope this will help you

Grails 3 JNDI datasource for Tomcat, Weblogic, Glassfish - Vs Grails 2

I'm experimenting with migrating from Grails 2 to Grails 3.
In Grails 2, I used this as my JNDI name within datasource.groovy file, within the Production-env
jndiName = "${(System.getProperty('catalina.home') && (System.getProperty('java.class.path')).trim().toLowerCase().indexOf('tomcat') > 0 ) ? 'java:comp/env/' : ''}jdbc/myGrails"
I found that worked well for me for Glassfish, Weblogic, and Tomcat.
However, when i try this in Grails 3, within the application.yml:
jndiName: ${(System.getProperty('catalina.home') && (System.getProperty('java.class.path')).trim().toLowerCase().indexOf('tomcat') > 0 ) ? 'java:comp/env/' : ''}jdbc/myGrails
I get this error when running "grails run-app":
| Error Error occurred running Grails CLI: mapping values are not allowed here
in 'reader', line 123, column 169:
... mcat') > 0 ) ? 'java:comp/env/' : ''}jdbc/traxGrails
^
(Use --stacktrace to see the full trace)
If I do use this in Grails 3:
jndiName: java:/comp/env/jdbc/myGrails
Then it works fine when using Grails run-app, and also works fine to deploy the WAR to Tomcat.
Can someone help me in getting my "jndi expression" from Grails 2 to work in Grails 3?
It looks like you're trying to use groovy syntax in a yml file, which does not work. You can create an application.groovy file (which will be merged with the application.yml file) if you want to use groovy syntax.
Also take a look at the many ways spring-boot allows you to inject properties via env variables, properties, yml, etc. http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html

getting grails 2.5.4 asset pipeline excludes to work

I am unable to get either the sass asset pipeline or the less asset pipeline plugin to work, if I am using sass or less imports.
If I only have one sass or less file, grail war works fine.
In my scenario however, file1.scss imports file2.scss, and in the end I only want to end up with a file1.css created from both. This should be possible according to this
https://grails.org/plugin/sass-asset-pipeline
But I am getting this output
| Minifying File 345 of 398 - file2.
| Error WAR packaging error: Stream closed
from grails war --stacktrace --verbose
Both files are in the same directory and have teh following contents:
file1.scss
#import "file2";
.brand {background-color:$mainColor;}
file2.scss
$mainColor: #277D85;
My build config has this:
plugins = {
...
compile ':asset-pipeline:2.5.7'
provided ":sass-asset-pipeline:2.9.1"
}
grails.assets.minifyJs = false
grails.assets.minifyCss = false
grails.assets.minifyOptions = [
optimizationLevel: 'WHITESPACE_ONLY'
]
grails.assets.excludes = ["**/file2.scss"]
What am I doing wrong?
How can I get more insights into what's going on here.
Your plugin block should remain in BuildConfig.groovy. However, the rest should be placed in Config.groovy

Grails and release plugin

I'm trying to use the release 2.0.4 plugin to deploy my war through grails 2.1.1 to artifactory server.
My BuildConfig.groovy has:
grails.project.repos.snap.url = "http://server:8080/artifactory/apps-snapshot-local"
grails.project.repos.snap.username = "user"
grails.project.repos.snap.password = "password"
grails.project.repos.rel.url = "http://server:8080/artifactory/apps-release-local"
grails.project.repos.rel.username = "user"
grails.project.repos.rel.password = "password"
grails.project.repos.default = "rel"
When I just do the "grails maven-deploy" it works and deploys to my rel server as expected. When I try to override the default target through the command line I get failures.
grails maven-deploy --repository=snap
I get this:
| Done creating WAR snap
| POM generated: C:\dev-git\DBUpdateWeb\target/pom.xml.
| Error Error deploying artifact: C:\dev-git\DBUpdateWeb\target\DBUpdateWeb.war (The system cannot find the file specified)
| Error Have you specified a configured repository to deploy to (--repository argument) or specified distributionManagement in your POM?
When I do specify the --repository tag it doesn't generate a war even though it says it did. Any help is appreciated. Thanks in advance.
Try grails maven-deploy "--repository=snap".
Also, specify app.version in application.properties so that the WAR will be standard compliant (1.0-SNAPSHOT for publishing to the snapshots repository and 1.0 for releases), and comment out the grails.project.war.file line in BuildConfig.groovy.

How to ignore Rails 3 assets from log [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to disable logging of asset pipeline (sprockets) messages in Rails 3.1?
is possible to hack logger in Rails3 to ignore requests for assets?
It is maddness to find something in log, when it is full of
Started GET "/assets/tiscali.png" for 127.0.0.1 at 2011-09-09 19:59:45 +0200
Served asset /tiscali.png - 304 Not Modified (0ms)
Thanks!
I think this could help https://github.com/evrone/quiet_assets
Deprecation
As of sprockets-rails version 3.1.0, used in current versions of rails, this gem is deprecated.
The asset pipeline now supports a quiet option which suppresses output of asset requests:
# config/environments/development.rb
config.assets.quiet = true
Relevant PR: https://github.com/rails/sprockets-rails/pull/355
Info
Quiet Assets turns off the Rails asset pipeline log. This means that it suppresses messages in your development log such as:
Started GET "/assets/application.js" for 127.0.0.1 at 2015-01-28 13:35:34 +0300
Served asset /application.js - 304 Not Modified (8ms)
Support Ruby on Rails >= 3.1...
Usage
Simply installing Quiet Assets will suppress the log messages automatically. However, if you wish to temporarily re-enable the logging of the asset pipeline messages, place the following in your config/application.rb file:
config.quiet_assets = false
If you need to suppress output for other paths you can do so by specifying:
config.quiet_assets_paths << '/silent/'
Apparently the issue is still open as of 02 Nov 2011.
A workaround solution is available in a similar question: How to disable logging of asset pipeline (sprockets) messages in Rails 3.1?
How about an invert selection?
tail -f log/development.log | grep -v asset
This basically outputs everything except for the lines that contain the word "asset".
Rails 3.2:
create a initializer with the content:
Rails::Rack::Logger.class_eval do
def call_with_quiet_assets(env)
previous_level = Rails.logger.level
Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0
call_without_quiet_assets(env).tap do
Rails.logger.level = previous_level
end
end
alias_method_chain :call, :quiet_assets
end
From here: https://github.com/rails/rails/issues/2639

Resources