bertramdev / asset-pipeline

The core implementation of the asset pipeline for the jvm
193 stars 92 forks source link

Chrome doesn't work with minified js #46

Closed wolandec closed 9 years ago

wolandec commented 9 years ago

Whilst firefox works well Chrome can't find libraries minified into js file, such as jquery, my customize js files and so on.

If I try to load file directly by url like this http://localhost:8080/assets/globalGraph-1c26099dbd37df815cc8204dd205999e.js Chrome shows something like that: //# sourceMappingURL=globalGraph.js.map

davydotcom commented 9 years ago

Care to provide more information. which grails version, which asset-pipeline version or have a sample app on github. Ive not run across minified js not working on either grails3 or grails2.x

wolandec commented 9 years ago

Grails 3.0.9 Asset-pipeline 3.0.8

This is my globalGraph.js

// This is a manifest file that'll be compiled into application.js. // // Any JavaScript file within this directory can be referenced here using a relative path. // // You're free to add application-wide JavaScript to this file, but it's generally better // to create separate JavaScript files as needed. // //= require ../bower_components/jquery/dist/jquery.min.js //= require ../bower_components/snap.svg/dist/snap.svg-min.js //= require ../bower_components/moment/min/moment-with-locales.min.js //= require ../bower_components/jQuery-contextMenu/src/jquery.ui.position.js //= require ../bower_components/jQuery-contextMenu/src/jquery.contextMenu.js //= require ../bower_components/pubsub-js/src/pubsub.js //= require ../bower_components/jQuery.Hotkeys/jquery.hotkeys.js //= require ../bower_components/jquery-ui/jquery-ui.min.js //= require ../bower_components/jsrender/jsrender.min.js //= require_tree src/js //= require_self //= require ../bower_components/bootstrap/dist/js/bootstrap.min.js

Actualy it works perfectly without bundle and I am happy developing with asset in IDE, but when I build jar file with gradle build command, asset collects my requires in one file and Chrome cant find jquery, for example.

davydotcom commented 9 years ago

few questions where is the bower_components folder relative to your project root

wolandec commented 9 years ago

The bower_components folder is in grails-app/assets.

davydotcom commented 9 years ago

If it is in the assets folder don't put it in your require paths like that. Folders are flattened at the first level of assets so

//= require ../bower_components/jquery/dist/jquery.min.js

should turn into

//= require jquery/dist/jquery.min.js

Also your versions are a bit old. Id bump to asset-pipeline:3.0.10 for grails 3 and for the gradle plugin id bump it to 2.6.2

wolandec commented 9 years ago

image

davydotcom commented 9 years ago

find and replace ../bower_components/ with

wolandec commented 9 years ago

Thank you very much! I changed ../bower_components/ to `` and it works!

davydotcom commented 9 years ago

the reason for that is a FileResolver is created in the resolvers list for each folder within assets. You were attempting to traverse outside of that FileResolver path into another resolvers fileset.

wolandec commented 9 years ago

Why Firefox works well at the same time?

davydotcom commented 9 years ago

it shouldn't matter at all. Im still not sure what your error is. It sounds like your referring to sourcemaps

wolandec commented 9 years ago

Anyway, thank you once more :)