Css provider with images not available after concat and minify

I use select2angular in the project (using yoman). Select2 css is located in the following directory:

bower_components / Select2 / select2.css bower_components / Select2 / select2.png

css uses select2.png as follows: background-image: url ('select2x2.png')

After doing concat and minify, I have the following structure:

bower_components / Select2 / d204997b.select2x2 styles /034d1972.vendor.css

But the problem is that part of select2 in venodr css is looking for d204997b.select2x2 in the styles directory.

This is my part of my GruntJS file:

rev: {
      dist: {
        files: {
          src: [
            '<%= yeoman.dist %>/scripts/{,*/}*.js',
            '<%= yeoman.dist %>/styles/{,*/}*.css',
            '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
            '<%= yeoman.dist %>/bower_components/select2/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
            '<%= yeoman.dist %>/styles/fonts/*'
          ]
        }
      }
    },
useminPrepare: {
  html: '<%= yeoman.app %>/index.html',
  options: {
    dest: '<%= yeoman.dist %>'
  }
},

usemin: {
  html: ['<%= yeoman.dist %>/{,*/}*.html'],
  css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
  options: {
    assetsDirs: ['<%= yeoman.dist %>' ,'<%= yeoman.dist %>/images' , '<%= yeoman.dist %>/bower_components/select2']
  }
}

thanks

+4
source share
1

. , , grunt- grunt-replace, css.

grunt

/**
 * Replaces image paths in CSS to match ../img. Select2 is the only css file this is needed for so far.
 * Others can be added.
 */
replace: {
    build: {
        src: ['<%= build %>/assets/lib/css/select2.css'],
        overwrite: true,
        replacements: [
            {
                from: /url\('(?!\.)/g,
                to: 'url(\'../img/'
            },
            {
                from: /url\((?!\')/g,
                to: 'url(\'../img/'
            },
            {
                from: /..\/images\//g,
                to: '../img/'
            },
            {
                from: /(png|gif|jpg)(?=\))/g,
                to: '$1\''
            }
        ]
    }
}

select2 "img". , , "to:" .

+3

All Articles