Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

Relative URLs in CSS sometimes won't be swapped to the revved file paths #242

Open
gsklee opened this issue Nov 20, 2013 · 11 comments
Open

Comments

@gsklee
Copy link

gsklee commented Nov 20, 2013

This works:

background: url('/images/phone.png'); ===(usemin)==> background: url('/images/53a6ac41.phone.png');

This also works:

background: url('images/phone.png'); ===(usemin)==> background: url('images/53a6ac41.phone.png');

This doesn't work (despite 53a6ac41.phone.png being in the right directory):

background: url('../images/phone.png'); ===(usemin)==> background: url('../images/phone.png');

@szimek
Copy link

szimek commented Nov 20, 2013

I have exactly opposite problem :)

When usemin task is executed, images are in dist/images, CSS src - .tmp/concat/styles/main.css and dest - dist/styles/main.css.

If I use absolute URL:

background: #c7a07f url('/images/phone.png');

it doesn't rev the file. I'm not sure what it treats as / path, but probably it can't find it in dist/styles.

If I use relative URL:

background: #c7a07f url('../images/phone.png');

it works fine.

The issue is that both versions work fine in development, so it's really easy to deploy messed up version. I'm using grunt-usemin 2.0.2 and grunt-contrib-cssmin 0.7.0.

@peterlarkin
Copy link

I've had the same issue as @gsklee.

When using relative paths in my CSS, the image files themselves get revved but when it gets to running "usemin:css", none of the references to these images are updated in the CSS.

As mentioned above, when I change the image references in my CSS to absolute paths, it does update the references properly during "usemin:css".

@theskumar
Copy link

+1.

@mrtorrent
Copy link

👍

Just to clarify, @peterlarkin more accurately describes the issue I'm seeing. @gsklee, do you agree? Are you saying that the paths in your CSS files don't get updated to point to the images with the revved file names?

If so, you may want to update the bug title and description, as it's a little misleading -- they make it sound like the paths in your CSS get updated with revved filenames but for some reason your browser can't find them.

Glad I'm not the only one having this issue! For now, rather than switching to absolute paths, I'm using @marcalj's workaround: yeoman/yeoman#824 (comment)

@marcalj
Copy link

marcalj commented Dec 18, 2013

+1 :)

@gsklee
Copy link
Author

gsklee commented Dec 18, 2013

@mrtorrent I've updated the issue to better described what I saw, got no idea what I was trying to say as well 🙀

@savanpalivela
Copy link

+1

ghillert added a commit to ghillert/spring-xd that referenced this issue Jan 17, 2014
ghillert added a commit to ghillert/spring-xd that referenced this issue Jan 21, 2014
ghillert added a commit to ghillert/spring-xd that referenced this issue Jan 24, 2014
ghillert added a commit to ghillert/spring-xd that referenced this issue Jan 28, 2014
@dmoreno
Copy link

dmoreno commented Jan 30, 2014

+1

ghillert added a commit to ghillert/spring-xd that referenced this issue Feb 3, 2014
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`
ilayaperumalg pushed a commit to spring-attic/spring-xd that referenced this issue Feb 4, 2014
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`
@htanjo
Copy link

htanjo commented Mar 14, 2014

+1

I also encountered the same situation and prevented it using @marcalj's trick. - yeoman/yeoman#824 (comment)
In my case, any name including non-existing directory seems to fix it.

usemin: {
  options: {
    assetsDirs: [
      '<%= path.dist %>',
      '<%= path.dist %>/any_name_is_ok'  // Fix relative path issue.
    ]
  },
  html: ['<%= path.dist %>/**/*.html'],
  css: ['<%= path.dist %>/**/*.css']
},

@tonyanhq
Copy link

tonyanhq commented Jun 9, 2014

@htanjo it works, thank you.

ghillert added a commit to ghillert/spring-xd-admin-ui-client that referenced this issue Apr 21, 2015
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`
@Ajaykumarkonda
Copy link

Ajaykumarkonda commented Nov 18, 2016

I also encountered same issue. Relative paths in html img src="images/image.png" is not working filerev but in css background image file rev is working
Any solution for html src paths for file rev.
I tried few solution but not worked

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

No branches or pull requests