'use strict';

module.exports = function(grunt) {

  // show elapsed time at the end
  //require('time-grunt')(grunt);

  grunt.initConfig({
    replace: {
      iconCSS: {
        options: {
          patterns: [{
            match: /url\('fonts\//g,
            replacement: 'url(\'/assets/fonts/'
          }]
        },
        files: [{
          src: './icomoon/style.css',
          dest: '.build/avicon-fonts.scss'
        }]
      },
      iconSCSS: {
        options: {
          patterns: [{
            match: /@font-face[^}]+}\s+/m,
            replacement: ''
          }, {
            match: /\[class\^="icon-"], \[class\*=" icon-"]/g,
            replacement: '@mixin avicon()'
          }, {
            match: /\.icon-([^:]+):before \{/g,
            replacement: '@mixin avicon_$1() {\n  @include avicon();'
          }]
        },
        files: [{
          src: './icomoon/style.css',
          dest: '.build/avicon-fonts-mixins.scss'
        }]
      }
    }
  });

  grunt.loadNpmTasks('grunt-replace');

  grunt.registerTask('build', ['replace']);
}
