I'm working on an AngularJS application with Yeoman.
The application depends on jQuery UI, which is installed with Bower. This is how I include the jQuery UI theme:
<!-- build:css styles/plugins.css -->
<link rel="stylesheet" href="components/jquery.ui/themes/base/jquery.ui.core.css" />
<link rel="stylesheet" href="components/jquery.ui/themes/base/jquery.ui.accordion.css" />
<link rel="stylesheet" href="components/jquery.ui/themes/base/jquery.ui.autocomplete.css" />
<link rel="stylesheet" href="components/jquery.ui/themes/base/jquery.ui.button.css" />
<link rel="stylesheet" href="components/jquery.ui/themes/base/jquery.ui.datepicker.css" />
<link rel="stylesheet" href="components/jquery.ui/themes/base/jquery.ui.dialog.css" />
<link rel="stylesheet" href="components/jquery.ui/themes/base/jquery.ui.menu.css" />
<link rel="stylesheet" href="components/jquery.ui/themes/base/jquery.ui.progressbar.css" />
<link rel="stylesheet" href="components/jquery.ui/themes/base/jquery.ui.resizable.css" />
<link rel="stylesheet" href="components/jquery.ui/themes/base/jquery.ui.selectable.css" />
<link rel="stylesheet" href="components/jquery.ui/themes/base/jquery.ui.slider.css" />
<link rel="stylesheet" href="components/jquery.ui/themes/base/jquery.ui.spinner.css" />
<link rel="stylesheet" href="components/jquery.ui/themes/base/jquery.ui.tabs.css" />
<link rel="stylesheet" href="components/jquery.ui/themes/base/jquery.ui.tooltip.css" />
<link rel="stylesheet" href="components/jquery.ui/themes/base/jquery.ui.theme.css" />
<!-- endbuild -->
When building the application, all goes well, without errors.
However, in the browser console (using Chrome), I can see that the images required by the jQuery UI Datepicker can't be found because it looks inside styles/images/
and they actually are inside components/...
.
Screenshot
My first idea was to override the jQuery UI image paths in CSS, but that doesn't seem like the best solution. Example:
Original styling
.ui-state-error .ui-icon,
.ui-state-error-text .ui-icon {
background-image: url(images/ui-icons_cd0a0a_256x240.png)/*{iconsError}*/;
}
My override
.ui-widget-header .ui-state-error {
background-image: url(../components/jquery.ui/themes/base/images/ui-bg_glass_95_fef1ec_1x400.png);
}
Any recommended solutions?
I had the same problem. But rather than changing the jQuery CSS (which could be harmful for future updates...), I just tweaked the "imagemin" task in the grunt script (Gruntfile.js) so that the images are copied where they are expected. This is true for any third party library as long as grunt takes care of modifying images pathes in the minified css.
Here is the change I made (please note that my jQuery UI theme folder is located under the app\styles
folder)
Before :
imagemin : {
dist : {
files : [{
expand : true,
cwd : '<%= yeoman.app %>/images',
src : '{,*/}*.{png,jpg,jpeg}',
dest : '<%= yeoman.dist %>/images'
}
]
}
}
After :
imagemin : {
dist : {
files : [{
expand : true,
cwd : '<%= yeoman.app %>/images',
src : '{,*/}*.{png,jpg,jpeg}',
dest : '<%= yeoman.dist %>/images'
}, {
expand : true,
flatten : true,
cwd : '<%= yeoman.app %>/styles',
src : '**/*.{png,jpg,jpeg,gif}',
dest : '<%= yeoman.dist %>/styles/images'
}
]
}
}
Hope this helps !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With