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
"usemin:css" doesn't generate correct image paths for relative urls #824
Comments
Also maybe worth noting is that the
|
Mainly:
|
So anything I can do right now to fix the issue? Should I use the master branch of yeoman or something? |
No, the master branch of usemin is currently not working. To do this you'll have to clone yeoman, checkout this particular commit, and change the version of yeoman in |
Great, thanks! I've branched it at https://github.com/taktran/yeoman/tree/usemin-patch. Couldn't figure out how to |
Thanks you guys!
|
When will this be fixed in yeoman? It seems like something people need to have fixed. |
@haraldringvold i guess they will fix this in yeoman 1.0, not sure though. |
Should be fixed by yeoman/grunt-usemin |
I had the same issue (with yeoman1.0.0-beta.4 and grunt 0.4.1) and solved it by adding basedir in the options of my Gruntfile.js
|
I had the same issue and I solved it like @olimungo but url image in css is not correct :( |
@dondinh : I've got something like this in my CSS: background-image: url(../images/ui/logo_40.png); It gets converted like this : background-image:url(../images/ui/47378ff3.logo_40.png) And I can find the following file in the "images" folder : 47378ff3.logo_40.png |
@olimungo : My issue is solved successful. Thank you very much |
I attempted @olimungo's solution above:
And received the following error:
After doing some research, this results from an issue with path.join(), and everyone's suggestion ends up resulting in reinstalling node and grunt and making sure everything is updated and pointing to the right location. I did all that without success. It turns out the solution is much simpler, remove the baseDir string from the array:
According to the usemin docs, baseDir is supposed to be a string anyways. |
I'm using v0.4.3 of Judging from the discussions above - is this an issue related with |
For anyone having troubles with this again, like me, I solved the issue appending "/images" path to
|
Thanks @marcalj, Was having this issue tonight and adding the /images folder to the assetsDir config worked perfectly. |
Thanks @josephspens ! It works! |
Thanks for @marcalj too ! |
For files inside JS you have to use manual replacement right now (issue opened): usemin: {
html: ['<%= yeoman.dist %>/{,*/}*.html'],
css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
js: '<%= yeoman.dist %>/scripts/*.js',
options: {
assetsDirs: ['<%= yeoman.dist %>', '<%= yeoman.dist %>/images'],
patterns: {
js: [[/(EuropeanUnion-24\.png)/, 'Replacing reference to EuropeanUnion-24.png']] // FIXME While usemin won't have full support for revved files we have to put all references manually here
}
}
}, |
You're are welcome :) |
Cool @marcalj! About the "files inside JS" issue - is it a |
@gsklee Here: yeoman/grunt-usemin#235 Make sure to use multiple regex to catch repeated filenames: yeoman/grunt-usemin#244 (comment) |
Cool, thanks @marcalj! |
Thanks @marcalj |
Thanks @marcalj, that worked like a charm! |
Thanks @marcalj! |
@tastycode Hey, thanks for your research. I use the NOTE: This goes to {
expand: true,
cwd: '<%= yeoman.app %>/bower_components/ionicons/fonts/',
src: ['**'],
dest: '<%= yeoman.dist %>/fonts/' // Ionicons copy hack
} With this approach you don't get font revved and minified, what about with your solution? Thanks! |
My solution gets revved (not sure if minified).. Honestly, if you solution works. I would rather just use it, i had to make so many changes everywhere to get mine to work. I don't need revving on these fonts. |
Use the
|
Thanks @marcalj ! |
Thanks @marcalj! |
Thanks @marcalj ! |
Another fix that I encounter was that I was getting messed up by relative paths within my URL link ('../../images'). If you have it in the format in parentheses, change it to ('/images') and that should fix a lot of issues. |
@iheanyi I would call that a bug. It's well defined that urls can relative from the CSS that include them. There is no excuse not to support that |
Please fix this. |
This is still an issue using yoeman 4.4, grunt contrib usemin 2.3 and the angular generator |
The original issue is old but I just had this problem, with the latest version of all components. I tried lot of config & setup (assetDirs, etc) that I gathered around on Github issues / stackoverflow, but nothing did the trick for my problem. The problem was like the original post, url(../images/bla.ext) was rewrote url(images/bla.ext) during cssmin. The problem was trusting the yeoman configuration template. I just removed the "root" configuration, and it solved everything. So from: Set: 6 hours lost, made my day though /o/ |
Thanks @Gamatora it works! |
Nice one @Gamatora . Resolved my generator-angular-phonegap headache :) |
Solution:
|
I was having an issue with this as well and the assetsDirs fixed it for me:
|
Without this, images are renamed, but the references to them in the CSS aren't updated correctly, which prevents the SUSE logo in the footer displaying. For further discussion, see yeoman/yeoman#824 (comment) It's curious that this fix doesn't seem to be necessary for dashboard/Gruntfile.js (are the files there not being renamed by rev?) Signed-off-by: Tim Serong <tserong@suse.com>
V 1.3.3 and still have the |
I'm having this issue as well @Ouadie - did you find any work around? |
For now I'm using |
Thank you kind sir. |
The Grunt-based build infrastructure is based on Yeoman's AngularJS support and then further customized. As part of `XD-1230`, this build process is then further integrated into the larger Spring XD Gradle build. Please see `README.md` for further details. * Add AngularUI Router dependency * Add UI-Router routes * Add LESS support + UI Admin Styles * Instead of customizing Bootstrap's `variables.less`, we instead import its styles into `main.less` and customize only the variables that changed. That way we can easily upgrade Bootstrap in the future * Fix a `grunt-usemin` issue with images in CSS files - Use fix as detailed here: yeoman/yeoman#824 (comment) - See also issue: yeoman/grunt-usemin#242 * Exclude vendor CSS, we already import the Bootstrap CSS via `main.less` * Don't use port 8080 for Karma tests in order to minimize conflicts with Tomcat * Add "Loading Indicator" support using `angular-busy` * Add Job launch support + Growl support + define XD Server URL globally * Use Bootstrap fonts from the distribution * Improve Job launch support * Update `.gitignore` * Update Nodejs dependencies, fix test dependencies - Running `npm install` should install all relevant dependencies from `package.json` * Add Gradle build support * Import CSS files as LESS resources in `main.less` - Otherwise you run into minification issues as Grunt's nsmin does not consider those CSS files * Remove old `admin-ui` * Improve resolving of the admin-ui URLs - http://localhost:9393/admin-ui --> http://localhost:9393/admin-ui/#/jobs/definitions - http://localhost:9393/admin-ui/ --> http://localhost:9393/admin-ui/#/jobs/definitions * Add task `cleanDist` * Improve Gradle build - Depend on `spring-xd-dirt:backgroundAdminServer` * Fix `xd.ui.home` in `application.yml` - `xd.ui.home` in `application.yml` should contain a trailing slash * Add `grunt-bower-task` to Grunt build - Allow Bower to be called via Grunt * Test that the UI builds with `gradle npmInstall installGrunt build` * Update Node dependency versions * Fix "Required config property "bower-install.app.src" missing" - Bower Install - In `Gruntfile.js`, change config `html: '<%= yeoman.app %>/index.html',` to `src: '<%= yeoman.app %>/index.html',` * Add Proxying to XD Admin Server via Grunt build - Add https://github.com/drewzboto/grunt-connect-proxy * Better error messages when pulling Job Definitions * Add `.bower_cache` directory local to project dir * Add Karma shell scripts - I find these shell scripts quite useful when writing unit and e2e tests as you can configure Karma to keep running as a daemon (automatically re-running the tests of code-changes do occur) * Add Grunt task `testfiles` - useful to prepare Spring XD test files * Add Karma Safari launcher * Add Unit and E2E tests * Remove unnecessary files - .gitattributes - app/.buildignore - app/robots.txt * Remove old loading Gif `loading.gif` - Remove unused related CSS * Ensure we use only single quotes in JS files * Improve Favicon support including mobile * Remove main.css + main.css.map (autogenerated) * Make sure LESS creates CSS files when executing `grunt serve` * Update `.gitignore` * Change Grunt Server Port to 8000 - Port 9000 conflicts with Sonar * Improve Gradle Build - `gradle build` will: - Install (if needed) node - Install (if needed) grunt - Download node dependencies for XD UI - Run the Grunt build * `gradle clean` will remove all unnecessary spring-xd-ui folders (e.g. local node modules, bower files etc) * Run Spring XD UI Grunt build on Eclipse STS import - Add task `afterEclipseImport` - See for details: https://issuetracker.springsource.com/browse/STS-2059 * Add `README.md` * Fix live-reloading of Html files * Fix copying of images in `Gruntfile.js` XD-1229 Code Review changes * Remove `.htaccess` * Run E2E as part of the Gradle test task * For distribution, copy Admin UI to `spring-xd-ui/dist`
Without this, images are renamed, but the references to them in the CSS aren't updated correctly, which prevents the SUSE logo in the footer displaying. For further discussion, see yeoman/yeoman#824 (comment) It's curious that this fix doesn't seem to be necessary for dashboard/Gruntfile.js (are the files there not being renamed by rev?) Signed-off-by: Tim Serong <tserong@suse.com> (cherry picked from commit 71b1cd791fe64aedc8c1cb766f37687075320e4e)
just encountered this problem in a project created very recently using yeoman 1.4.8 There was a subtle difference though. The default looked like:
which didn't work (the asset reference in the stylesheet wasn't updated by usemin). To get it working, I added the assets directory into the assetsDirs array:
which resolved the issue. |
Thanks @viz. adding assets directory did the trick! |
None of the solutions here worked for me. This solved my problem. |
I've generated a project using yeoman, and I have the following scss file which references an image using relative paths:
However, it does not get properly converted to the correct
../img/[random-hash].insulin-v2.jpg
format.If I change it to an absolute path, it does convert it correctly, ie,
...generates this in the
yeoman build
output(the previous relative url version doesn't produce any output after
Running "usemin:css" (usemin) task
)I can't use absolute paths because I need to host somewhere where it is not the root directory. Any ideas?
My folder structure is
Gruntfile.js
build settings areThis could be related to #419, but I tried the
.compass.rb
file addition and therelative_assets: true
, but they both didn't work.The text was updated successfully, but these errors were encountered: