Ejemplo n.º 1
0
module.exports = function (grunt) {

  var mozjpeg = require('imagemin-mozjpeg');
  var sass = require('node-sass');

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    clean: ['dist', '.tmp'],

    copy: {
      dist: {
        files: [
          { expand: true, src: ['src/index.html'], dest: 'dist/', filter: 'isFile', flatten: true },
          { expand: true, src: ['src/sitemap.xml'], dest: 'dist/', filter: 'isFile', flatten: true },
          { expand: true, src: ['src/favicon.ico'], dest: 'dist/', filter: 'isFile', flatten: true },
          { expand: true, src: ['src/font/*'], dest: 'dist/font/', flatten: true },
          { expand: true, src: ['src/data/*'], dest: 'dist/data/', flatten: true },
          { expand: true, src: ['src/template/*'], dest: 'dist/template/', flatten: true },
          { expand: true, src: ['src/img/*'], dest: 'dist/img/', flatten: true }
        ]
      }
    },

    useminPrepare: {
      html: ['src/index.html']
    },

    usemin: {
      options: {
        blockReplacements: {
          js: function (block) {

            return '<script async src="' + block.dest + '"><\/script>';
          }
        }
      },
      html: ['dist/index.html']
    },

    sass: {
      options: {
        implementation: sass,
        sourceMap: true
      },
      build: {
        files: {
          'src/style/main.css': 'src/style/main.scss'
        }
      }
    },

    postcss: {
      options: {
        processors: [
          require('autoprefixer')({
            browsers: ['> 5%', 'last 2 versions', 'IE 8', 'IE 9']
          }),
          require('cssnano')()
        ],
        map: true
      },

      build: {
        files: {
          'dist/css/style.min.css': 'src/style/main.css'
        }
      }
    },

    ngAnnotate: {
      options: {
        singleQuotes: true
      },
      dist: {
        files: {
          '.tmp/ngAnnotate/app.js': [
            'src/script/app.js',
            'src/script/routes.js',
            'src/script/services/jsonLoader.js',
            'src/script/services/metaTags.js',
            'src/script/controllers/navCtrl.js',
            'src/script/controllers/metaCtrl.js',
            'src/script/controllers/projectCtrl.js',
            'src/script/controllers/projectMetaCtrl.js',
            'src/script/components/dashcaseFilter.js',
            'src/script/components/feedReader.js'
          ]
        }
      }
    },

    uglify: {
      dist: {
        files: {
          '.tmp/uglify/app.min.js': ['.tmp/ngAnnotate/app.js']
        }
      }
    },

    concat: {
      options: {
        separator: ';',
        sourceMap: true
      },
      dist: {
        src: [
          'node_modules/angular/angular.min.js',
          'node_modules/angular-route/angular-route.min.js',
          '.tmp/uglify/app.min.js'
        ],
        dest: 'dist/src/main.min.js'
      }
    },

    'json-minify': {
      dist: {
        files: 'dist/data/*.json'
      }
    },

    imagemin: {
      jpg: {
        options: {
          progressive: true,
          use: [mozjpeg()]
        },
        files: [{
          expand: true,
          cwd: 'src/img/project/',
          src: ['*.jpg'],
          dest: 'dist/img/project/',
          ext: '.jpg'
        }]
      }
    },

    watch: {

      css: {

        files: 'src/style/**/*.scss',
        tasks: ['sass', 'postcss']
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-sass');
  grunt.loadNpmTasks('grunt-postcss');
  grunt.loadNpmTasks('grunt-usemin');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-ng-annotate');
  grunt.loadNpmTasks('grunt-json-minify');
  grunt.loadNpmTasks('grunt-contrib-imagemin');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('dist', [
    'clean', 'copy', 'useminPrepare', 'sass', 'postcss', 'ngAnnotate', 'uglify', 'concat', 'usemin', 'json-minify', 'imagemin'
  ]);
};
Ejemplo n.º 2
0
  })
  .setPublicPath(`${dist}`)
  .webpackConfig({
    plugins: [
      new CopyWebpackPlugin([
        {
          from: `${src}/images`,
          to: `images`
        }
      ]),
      new ImageminPlugin({
        optipng: { optimizationLevel: 7 },
        gifsicle: { optimizationLevel: 3 },
        pngquant: { quality: '65-90', speed: 4 },
        svgo: { removeUnknownsAndDefaults: false, cleanupIDs: true },
        plugins: [imageminMozjpeg({ quality: 80 })]
      })
    ]
  });

/**
 * Web fonts.
 */
mix.copy(`${src}/fonts`, `${dist}/fonts`);

/**
 * Main assets (JS & CSS).
 */
mix.js(`${src}/scripts/main.js`, `${dist}/scripts`);
mix.sass(`${src}/styles/main.scss`, `${dist}/styles`, {
  implementation: require('node-sass')
module.exports = function(grunt) {

  // Load the plugins
  require('load-grunt-tasks')(grunt);

  //mozjpeg is a production-quality JPEG encoder that improves compression while maintaining compatibility with the vast majority of deployed decoders
  var mozjpeg = require('imagemin-mozjpeg');

  // constants for various paths and files to be used by the task configuration
  /* Source Directories */
  // Source Base
  var SRC_DIR         = "src/";

  // HTML base source
  var SRC_DIR_HTML    = SRC_DIR + "site/";
  // Include base source
  var SRC_DIR_INCLUDE = SRC_DIR_HTML + "include";
  // Source HTML files
  var SRC_FILES_HTML  = [SRC_DIR_HTML + "*.html", SRC_DIR_HTML + "pages/*.html", SRC_DIR_HTML + "include/*.html"];

  // Source Directory
  var SRC_DIR_JS      = SRC_DIR + "js/";
  var SRC_DIR_CSS     = SRC_DIR + "css/";
  var SRC_DIR_LESS    = SRC_DIR + "less/";

  // Source files
  var SRC_FILES_JS    = SRC_DIR_JS   + "*.js";
  var SRC_FILES_CSS   = SRC_DIR_CSS  + "*.css";
  var SRC_FILES_LESS  = SRC_DIR_LESS + "**/*.less";

  // Browser prefix for Autoprefixing
  var AP_BROWSERS = [
  "Android >= 4",
  "Chrome >= 35",
  "Firefox >= 35",
  "Explorer >= 7",
  "iOS >= 6",
  "Opera >= 20",
  "Safari >= 9"
  ];

  /* Output Directories */
  // Destination Base
  var BUILD_DIR       = "dist/";

  // Stylesheet
  var BUILD_DIR_CSS   = BUILD_DIR     + "css/";
  var BUILD_FILES_CSS = BUILD_DIR_CSS + "*.css";

  // JavaScripts
  var BUILD_DIR_JS    = BUILD_DIR     + "js/";
  var BUILD_FILE_JS   = BUILD_DIR_JS  + "script.js";
  var BUILD_FILES_JS  = BUILD_DIR_JS  + "*.js";


  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    // clean each destination before output
    clean: {
      html: ["dist/**/*.html"],
      stylesall: [SRC_FILES_CSS, BUILD_FILES_CSS],
      stylesbuild: [BUILD_FILES_CSS],
      js : [BUILD_FILES_JS]
    },

    // Build the site using grunt-includes
    includes: {
      build: {
        cwd: SRC_DIR_HTML,
        src: [ "*.html", "pages/*.html" ],
        dest: BUILD_DIR,
        options: {
          flatten: true,
          duplicates: false,
          includePath: SRC_DIR_INCLUDE
        }
      }
    },

    // Changes the path using grunt-processhtml
    processhtml: {
      build: {
        expand: true,
        cwd: BUILD_DIR,
        src: ['**/*.html'],
        dest: BUILD_DIR
      }
    },

    // all in one processor of the LESS to CSS
    cssflow: {
      options: {
        preprocessor: 'less',
        autoprefixer: {
          browsers: AP_BROWSERS
        },
        cssmin: {
          keepSpecialComments: 0
        }
      },
      build: {
        files: {
          'src/css/style.css': 'src/less/main.less'
        }
      }
    },

    // copy CSS from source directory to dist folder
    copy: {
      styles: {
        expand: true,
        cwd: SRC_DIR_CSS,
        src: ['*.css'],
        dest: BUILD_DIR_CSS
      }
    },

    // remove unused CSS selector
    uncss: {
      build: {
        files: [
          {
            src: 'src/site/index.html',
            dest: 'dist/css/style.uncss.css'
          }
        ],
        options: {
          ignoreSheets: [/fonts.googleapis/]
        }
      }
    },

    // Validate files with JSHint
    jshint: {
      options: {
        reporter: require('jshint-stylish'),
        curly: true,
        globals: {
          jQuery: true
        }
      },
      beforeconcat: [SRC_FILES_JS],
      afterconcat: [BUILD_FILE_JS]
    },

    // Concatenate javascript files
    concat: {
      options: {
        seperator: ";"
      },
      build: {
        src: [SRC_FILES_JS],
        dest: BUILD_FILE_JS
      }
    },

    // Minify files with UglifyJS
    uglify: {
      options: {
        // the banner is inserted at the top of the output
        banner: '/*! <%= grunt.template.today("dd-mm-yyyy HH:MM") %> */\n'
      },
      build: {
        files: {
          'dist/js/script.min.js': BUILD_FILE_JS
        }
      }
    },

    // Minify images
    imagemin: {
      dynamic: {
        options: {
          optimizationLevel: 1,
          progressive: false,
          svgoPlugins: [{ removeViewBox: false }],
          use: [mozjpeg({quality: 75})]
        },
        files: [{
          expand: true,
          cwd: 'src/images/',
          src: ['**/*.{png,jpg,gif}'],
          dest: 'dist/images/'
        }]
      }
    },

    // Bump package version, create tag, commit, push ...
    bump: {
      options: {
        files: ['package.json'],
        updateConfigs: [],
        commit: true,
        commitMessage: 'Release v%VERSION%',
        commitFiles: ['package.json'],
        createTag: true,
        tagName: 'v%VERSION%',
        tagMessage: 'Version %VERSION%',
        push: true,
        pushTo: 'upstream',
        gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d',
        globalReplace: false,
        prereleaseName: false,
        metadata: '',
        regExp: false
      }
    },

    watch: {
      configFiles: {
        options: {
          reload: true
        },
        files: [ 'Gruntfile.js'],
      },
      html: {
        options: {
          spawn: false
        },
        files: SRC_FILES_HTML,
        tasks: ['includes']
      },
      styles: {
        options: {
          spawn: false
        },
        files: [SRC_FILES_LESS],
        tasks: ['cssflow', 'clean:stylesbuild', 'copy:styles']
      },
      scripts: {
        options: {
          spawn: false
        },
        files: ['src/js//*.js'],
        tasks: ['jshint:beforeconcat', 'clean:js', 'concat', 'uglify', 'jshint:afterconcat']
      },
      images: {
        options: {
          spawn: false
        },
        files: ['src/images/**/*.{png,jpg,gif}'],
        tasks: ['compress']
      }
    }
  });

  //Default Tasks
  grunt.registerTask('default', ['includes', 'clean:stylesall', 'cssflow', 'copy:styles']);

  // Production tasks
  grunt.registerTask('dev', ['includes', 'clean:stylesall', 'cssflow', 'copy:styles', 'watch']);
  // Build Tasks changes path variables for uploading
  grunt.registerTask('build', ['includes', 'processhtml']);

  //Test Tasks for travis
  grunt.registerTask('test', ['includes', 'clean:stylesall', 'cssflow', 'copy:styles']);
  // Image compressing task
  grunt.registerTask('compress', ['newer:imagemin']);
  // remove unused css class
  grunt.registerTask('cleancss', ['uncss', 'cssmin:dist']);
};
Ejemplo n.º 4
0
gulp.task(taskName.image.release, function () {
    return gulp.src(imageOpt.src)
        .pipe(imagemin({ use: [pngquant(imageOpt.png), mozjpeg(imageOpt.jpg), svgo()] }))
        .pipe(gulp.dest(imageOpt.dest.release));
});
Ejemplo n.º 5
0
module.exports = function( grunt ){
    var mozjpeg = require('imagemin-mozjpeg');
    grunt.initConfig({
        uglify: {
            options: {
                mangle: false
            },
            file_min_js: {
                files: {
                    'assets/js/main.min.js': ['assets/_js/main.js']
                }
            }
        }, //uglify
        sass : {
            dist:{
                options:{style:'compressed'},
                files:{
                    'assets/css/style.min.css': 'assets/_sass/style.scss'
                }
            }
        }, // sass

        watch: {
            dist: {
                files: ['assets/_js/**/*','assets/_sass/**/*'],
                tasks: ['concat','uglify','sass']
            }
        }, // watch

        shell:{
            options:{
                stderr:false
            },
            mkdir:{
                command: function(dir){
                    return 'mkdir '+ dir;
                }
            }
        }, //shell
        concat: {
            js: {
                src: 'assets/_js/_src/*.js',
                dest: 'assets/_js/main.js'
            }
        }, // concat

        imagemin: {
            dynamic: {
                options: {
                    optimizationLevel: 3,
                    svgoPlugins: [{ removeViewBox: false }],
                    use: [mozjpeg()]
                },// Another target
                files: [{
                    expand: true,                  // Enable dynamic expansion
                    cwd: 'assets/_img',                   // Src matches are relative to this path
                    src: ['**/*.{png,jpg,gif}'],   // Actual patterns to match
                    dest: 'assets/img/'                  // Destination path prefix
                }]
            }
        }


    });

    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-shell');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-imagemin');

    grunt.registerTask('default', ['uglify','sass']);
    grunt.registerTask('w', ['watch']);
    grunt.registerTask('mk', function(dir){
        grunt.task.run('shell:mkdir:' + dir);
    });
    grunt.registerTask('c', ['concat']);
    grunt.registerTask('img', ['imagemin']);

};
Ejemplo n.º 6
0
    minify = require('imagemin')();

// command-line
command
    .version(pkg.version)
    .option('-q, --quality [level]', 'specify quality of compression', app.quality)
    .parse(process.argv);

var mozjpeg = require('imagemin-mozjpeg'),
    defaults = {
        jpegQuality: 90
    };

// minification
minify
    .src('*.{gif,jpg,png,svg}')
    .dest('optimized')
    .use(mozjpeg({
        quality: (app.quality) ? app.quality : defaults.jpegQuality
    }))
    .use(pngquant({

    }))
    .run(function(err, files) {
        files.forEach(function(file) {
            fs.stat(file.path, function(err, stat) {
                console.log(path.basename(file.path) + ' - ' + stat.size + 'kb');
            });
        });
    });
Ejemplo n.º 7
0
module.exports = function (grunt) {
  "use strict";
  var mozjpeg = require ('imagemin-mozjpeg');
  // Project configuration.
  grunt.initConfig({
    clean: {
  		main: ["dist"]
	  },
    imagemin: {                          // Task
      /*static: {                          // Target
        options: {                       // Target options
          optimizationLevel: 3,
          svgoPlugins: [{ removeViewBox: false }],
          use: [mozjpeg()]
        },
        files: {                         // Dictionary of files
          'dist/img.png': 'src/img.png', // 'destination': 'source'
          'dist/img.jpg': 'src/img.jpg',
          'dist/img.gif': 'src/img.gif'
        }
      },*/
      dynamic: {                         // Another target
        options: {                       // Target options
          optimizationLevel: 3,
          svgoPlugins: [{ removeViewBox: false }],
          use: [mozjpeg()]
        },
        files: [{
          expand: true,                  // Enable dynamic expansion
          cwd: 'assets/images',                   // Src matches are relative to this path
          src: ['**/*.{png,jpg,gif}'],   // Actual patterns to match
          dest: 'dist/assets/images'                  // Destination path prefix
        }]
      }
    },
    compress: {
		  main: {
		    options: {
		      mode: 'gzip'
		    },
		    expand: true,
		    cwd: '.',
		    src: ['**/*','!**/node_modules/**','!**/dist/**','!LICENSE','!README.md','!Gruntfile.js','!index.html','dist/index.html'],
		    dest: 'dist/'//,

		  }
    },
    processhtml: {
      dist: {
        files: {
          'dist/index.html': ['index.html']
        }
      }
    },
    htmlmin: {
			dev: {
				options: {
					removeComments: true,
					collapseWhitespace: true
				},
        files: {
        'dist/index.html': 'dist/index.html'
        }
			}
  	},
    cssmin: {
            bundle: {
                options: {
                    banner: '/* xDevel Sistemas */'
                },
                files: {
                    'dist/assets/css/bundle.css': ['assets/css/*.css'],
                }
            }
        },
    uglify: {
            options: {
                compress: true
            },
            bundle: {
                src: [
                  'lib/jquery/dist/jquery.js',
                	'lib/jquery.scrollTo/jquery.scrollTo.js',
                	'lib/jquery.localScroll/jquery.localScroll.js',
                	'lib/jquery-form/jquery.form.js',
                	'lib/jquery-validation/dist/jquery.validate.js',
                	'assets/js/waypoints.min.js',
                	'assets/js/bootstrap.min.js',
                	'assets/js/mc-validate.js',
                	'assets/js/jquery.prettyPhoto.js',
                	'assets/js/scripts.js'],
                dest: 'dist/assets/js/bundle.js'
            }
    },
    copy: {
  	  main: {
  	    files: [
  	      // includes files within path and its sub-directories
  	      {expand: true, src: ['**/*','!**/*.{png,jpg,gif,css,js}','!**/dist/**','!**/node_modules/**'], dest: 'dist/'}
  	    ]
  	  }
	  }

  });

  grunt.loadNpmTasks('grunt-contrib-imagemin');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-compress');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-processhtml');
  grunt.loadNpmTasks('grunt-contrib-htmlmin');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-cssmin');



  // Default task(s).
  grunt.registerTask('default', ['clean','copy','processhtml','htmlmin','cssmin','uglify','imagemin']);

};
Ejemplo n.º 8
0
const parser = require('./parser');
const imagemin = require('gulp-imagemin');
const imageminSvgo = require('imagemin-svgo');
const imageminMozjpeg = require('imagemin-mozjpeg');
const imageminPngquant = require('imagemin-pngquant');

module.exports = parser([
	imagemin({
		plugins: [
			imageminMozjpeg(),
			imageminPngquant({quality: '65-80'}),
			imageminSvgo()
		]
	})
]);
Ejemplo n.º 9
0
module.exports = function (grunt) {

    var mozjpeg = require('imagemin-mozjpeg');

    // 1. All configuration goes here 
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),


        clean : {
            yourTarget : {
                src : [ "public/img/dist/*", 
                        "public/html/dist/*", 
                        "public/css/dist/*",
                        "public/js/dist/*"
                ]
            }
        },

        concat: {
            css: {
                src: [
                    'public/css/bootstrap.min.css',
                    //'public/css/font-awesome.css', //not included for now
                    'public/css/lato-font.css', //download of http://fonts.googleapis.com/css?family=Lato:300,400,700
                    'public/css/custom.css' 
                ],
                dest: 'public/css/dist/app-concat.css'

            },

            js: {

                files: [
                    { 
                        //files for core angular files
                        src: [  
                            //These must be in the correct order
                            'public/js/libs/jquery.min.js',
                            'public/js/libs/bootstrap.min.js',
                            'public/js/libs/angular.min.js',
                            'public/js/libs/angular-route.js',
                            'public/js/libs/angular-resource.min.js', 
                            'public/js/libs/angular-cookies.min.js', 
                            'public/js/libs/angular-animate.min.js', 
                            'public/js/libs/ui-bootstrap-tpls-0.10.0.min.js',

                            //app.js goes first, then the controllers and factories
                            'public/js/app.js',
                            'public/js/controllers/*',
                            'public/js/factories/*'
                            
                            ], 

                        dest: 'public/js/dist/app-concat.js' 
                    }
                ],
                options: {
                    preserveComments: false
                }
            }
        },
        cssmin: {
            css: {
                src: 'public/css/dist/app-concat.css',
                dest: 'public/css/dist/app.min.css'
            },
            options: {
                keepSpecialComments: 0
            }
        },


        htmlmin: {                                     // Task
          dist: {                                      // Target
            options: {                                 // Target options
              removeComments: true,
              collapseWhitespace: true
            },
            files: {                                   
              'public/html/dist/index.html': 'public/html/index.html'
            }
          }

          // dev: {                                       // Another target
          //   files: {
          //     'dist/index.html': 'src/index.html',
          //     'dist/contact.html': 'src/contact.html'
          //   }
          // }
        },


        imagemin: {
            // png: {
            //   options: {
            //     optimizationLevel: 7
            //   },
            //   files: [
            //     {
            //       // Set to true to enable the following options…
            //       expand: true,
            //       // cwd is 'current working directory'
            //       cwd: 'public/img/',
            //       src: ['**/*.png'],
            //       // Could also match cwd line above. i.e. project-directory/img/
            //       dest: 'public/img/dist/',
            //       ext: '.png'
            //     }
            //   ]
            // },
            // jpg: {
            //   options: {
            //     progressive: true
            //   },
            //   files: [
            //     {
            //       // Set to true to enable the following options…
            //       expand: true,
            //       // cwd is 'current working directory'
            //       cwd: 'public/img/',
            //       src: ['**/*.jpg'],
            //       // Could also match cwd. i.e. project-directory/img/
            //       dest: 'public/img/dist/',
            //       ext: '.jpg'
            //     }
            //   ]
            // },
            // gif: {
            //   options: {
            //     progressive: true
            //   },
            //   files: [
            //     {
            //       // Set to true to enable the following options…
            //       expand: true,
            //       // cwd is 'current working directory'
            //       cwd: 'public/img/',
            //       src: ['**/*.gif'],
            //       // Could also match cwd. i.e. project-directory/img/
            //       dest: 'public/img/dist/',
            //       ext: '.gif'
            //     }
            //   ]
            // }

            dynamic: {                         // Another target
              options: {                       // Target options
                optimizationLevel: 3,
                svgoPlugins: [{ removeViewBox: false }],
                use: [mozjpeg()]
              },
              files: [{
                expand: true,                  // Enable dynamic expansion
                cwd: 'public/img/',                   // Src matches are relative to this path
                src: ['**/*.{png,jpg,gif}'],   // Actual patterns to match
                dest: 'public/img/dist/'                  // Destination path prefix
              }]
            }
        },


        uglify: {
            js: {

                files: [
                  { src: 'public/js/dist/app-concat.js', dest: 'public/js/dist/app.min.js' }

                ],
                options: {
                    preserveComments: false,
                    //set mangle to false for Angular, since doesn't play nice
                    mangle: false
                }

            }
        }
        // watch: {
        //     // css: {
        //     //     files: ['public/assets/css/*.cs'],
        //     //     tasks: ['concat:css', 'cssmin:css']
        //     // },
        //     js: {
        //         files: ['public/scipts/dist/*.js'],
        //         tasks: ['concat:js', 'uglify:js']
        //     }
        // }

    });

    // 2. Where we tell Grunt we plan to use this plug-in.
    grunt.loadNpmTasks("grunt-contrib-clean");
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    //grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-imagemin');
    grunt.loadNpmTasks("grunt-contrib-htmlmin");

    // 3. Where we tell Grunt what to do when we type "grunt" into the terminal.
    //grunt.registerTask('default', ['concat', 'cssmin', 'uglify']);
    //grunt.registerTask('default', ['concat', 'cssmin', 'uglify', 'imagemin', 'htmlmin']);
    grunt.registerTask('default', ['clean', 'concat', 'cssmin', 'uglify', 'imagemin', 'htmlmin']);



};
Ejemplo n.º 10
0
module.exports = function(grunt) {

    // auto-load all grunt tasks matching the `grunt-*` pattern in package.json
    // no need for grunt.loadNpmTasks!
    require('load-grunt-tasks')(grunt);
    var mozjpeg = require('imagemin-mozjpeg');

    grunt.initConfig({

        /**
        *
        * Variables
        *
        */
			
        // Variables from package.json
        pkg: grunt.file.readJSON( 'package.json' ),

        // Global variables
        vars: grunt.file.readJSON( 'gruntVars.json' ),
        
        // README
        rdm: 'README.md', 

        /**
        *
        * Grunt plugin configuration
        *
        */

        // autoprefixer
        autoprefixer: {
            options: {
                browsers: ['last 2 versions', 'ie 9'],
                map: true
            },
            target_file: {
               src: '<%= vars.theme_path %>/<%= vars.theme_name %>/style.css',
            },
        },

        // Increment the version number in package.json
	  	bump: {
			options: {
  			    updateConfigs: ['pkg'], // make sure to check updated pkg variables
  			    push: false,
                commitFiles: ['-a'], // Commit all files
                createTag: false, // Branch is tagged by git flow
                commitMessage: 'Bump the version to %VERSION%',
                prereleaseName: 'rc',
			}
		},

        // Delete temporary files
		clean: {
            dir_release: ['release/**/*'], // Clean out the release dir
            copy_theme: ['release/<%= pkg.name %>.<%= pkg.version %>/<%= vars.theme_name %>.<%= pkg.version %>'],
			copy_plugin: ['release/<%= pkg.name %>.<%= pkg.version %>/<%= vars.plugin_name %>.<%= pkg.version %>']
		},

        // Create an archive
		compress: {

			plugin: {
				options: {
					mode: 'tgz',
					archive: 'release/<%= pkg.name %>.<%= pkg.version %>/<%= vars.plugin_name %>.<%= pkg.version %>.tgz'
				},
				expand: true,
				cwd: 'release/<%= pkg.name %>.<%= pkg.version %>/<%= vars.plugin_name %>.<%= pkg.version %>',
				src: ['**/*']
			},

            theme: {
                options: {
                    mode: 'tgz',
                    archive: 'release/<%= pkg.name %>.<%= pkg.version %>/<%= vars.theme_name %>.<%= pkg.version %>.tgz'
                },
                expand: true,
                cwd: 'release/<%= pkg.name %>.<%= pkg.version %>/<%= vars.theme_name %>.<%= pkg.version %>',
                src: ['**/*']
            },
            theme_pot: {
                options: {
                    mode: 'zip',
                    archive: 'release/<%= pkg.name %>.<%= pkg.version %>/_criadoemsampa.pot.<%= pkg.version %>.zip'
                },
                expand: true,
                cwd: 'release/<%= pkg.name %>.<%= pkg.version %>/<%= vars.theme_name %>.<%= pkg.version %>/languages/',
                src: ['*.pot']
            },
            plugin_pot: {
                options: {
                    mode: 'zip',
                    archive: 'release/<%= pkg.name %>.<%= pkg.version %>/_criadoemsampa_plugin.pot.<%= pkg.version %>.zip'
                },
                expand: true,
                cwd: 'release/<%= pkg.name %>.<%= pkg.version %>/<%= vars.plugin_name %>.<%= pkg.version %>/languages/',
                src: ['*.pot']
            },   		
		},

        copy: {

            theme: {
                files:  [ 
                    {
                        expand: true, // includes files within path and its sub-directories
                        cwd: '<%= vars.theme_path %>/<%= vars.theme_name %>/', // Target dir
                        src: [
                            '**',
                            '!style.css.map',
                            '!**/*.*.orig' // Don't copy .orig copies
                        ], 
                        dest: 'release/<%= pkg.name %>.<%= pkg.version %>/<%= vars.theme_name %>.<%= pkg.version %>'
                    },
                ],
            },

            plugin: {
                files:  [
                    // includes files within path and its sub-directories
                    {expand: true, 
                    cwd: '<%= vars.plugin_path %>/<%= vars.plugin_name %>', // Target dir
                    src: [
                        '**',
                        '!**/*.*.orig' // Don't copy .orig copies
                    ], 
                    dest: 'release/<%= pkg.name %>.<%= pkg.version %>/<%= vars.plugin_name %>.<%= pkg.version %>'},
                    ],
            },

            mu_plugins: {
                files:  [
                    // includes files within path and its sub-directories
                {expand: true, 
                    cwd: 'httpdocs/wp-content/mu-plugins/',
                    src: [
                        '**',
                    ], 
                    dest: 'release/<%= pkg.name %>.<%= pkg.version %>/<%= vars.mu_plugin_path %>'},
                    ],
            },

            font_awesome: {
                 expand: true,
                 flatten: true,
                 src: ['bower_components/fontawesome/fonts/*'],
                 dest: '<%= vars.theme_path %>/<%= vars.theme_name %>/assets/fonts'
            },

            deploy_scripts: {
                 expand: true,
                 flatten: true,
                 src: ['node_modules/mbd-wp-deploy-scripts/scripts/*'],
                 dest: 'scripts'
            }
        },

        // Optimize images
        imagemin: {
            dist: {
                options: {
                    optimizationLevel: 7,
                    progressive: true,
                    interlaced: true,
                    use: [mozjpeg()],
                },
                files: [{
                    expand: true,
                    cwd: '<%= vars.theme_path %>/<%= vars.theme_name %>/assets/images/src',
                    src: ['**/*.{png,jpg,jpeg,gif}'],
                    dest: '<%= vars.theme_path %>/<%= vars.theme_name %>/assets/images/dist'
                }]
            }
        },

        // javascript linting with jshint
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                "force": true
            },
            all: [
                'Gruntfile.js',
                '<%= vars.theme_path %>/<%= vars.theme_name %>/assets/js/src/custom/**/*.js',
                '<%= vars.plugin_path %>/<%= vars.plugin_name %>/assets/js/src/custom/**/*.js',
            ]
        },

        makepot: {
            theme: {
                options: {
                    cwd: 'httpdocs/wp-content/themes/<%= vars.theme_name %>',
                    exclude: ['httpdocs/wp-content/themes/<%= vars.theme_name %>/assets/'],
                    type: 'wp-theme',
                    processPot: function( pot ) {
                        var translation,
                            excluded_meta = [
                                'Plugin Name of the plugin/theme',
                                'Plugin URI of the plugin/theme',
                                'Author of the plugin/theme',
                                'Author URI of the plugin/theme'
                            ];

                        for ( translation in pot.translations[''] ) {
                            if ( 'undefined' !== typeof pot.translations[''][ translation ].comments.extracted ) {
                                if ( excluded_meta.indexOf( pot.translations[''][ translation ].comments.extracted ) >= 0 ) {
                                    console.log( 'Excluded meta: ' + pot.translations[''][ translation ].comments.extracted );
                                    delete pot.translations[''][ translation ];
                                }
                            }
                        }

                        return pot;
                    },
                    updatePoFiles: false  
                }
            },
            plugin: {
                options: {
                    cwd: 'httpdocs/wp-content/plugins/<%= vars.plugin_name %>',
                    type: 'wp-plugin',
                    processPot: function( pot ) {
                        var translation,
                            excluded_meta = [
                                'Plugin Name of the plugin/theme',
                                'Plugin URI of the plugin/theme',
                                'Author of the plugin/theme',
                                'Author URI of the plugin/theme'
                            ];

                        for ( translation in pot.translations[''] ) {
                            if ( 'undefined' !== typeof pot.translations[''][ translation ].comments.extracted ) {
                                if ( excluded_meta.indexOf( pot.translations[''][ translation ].comments.extracted ) >= 0 ) {
                                    console.log( 'Excluded meta: ' + pot.translations[''][ translation ].comments.extracted );
                                    delete pot.translations[''][ translation ];
                                }
                            }
                        }

                        return pot;
                    },
                    updatePoFiles: false  
                }
            },
        },

        // Modernizr
        modernizr: {
            dist: {
                // [REQUIRED] Path to the build you're using for development.
                "devFile" : "bower_components/modernizr/modernizr.js",

                // Path to save out the built file.
                "outputFile" : "<%= vars.theme_path %>/<%= vars.theme_name %>/assets/js/dist/custom/modernizr-custom.js",
            }
        },

        // Sass
        sass: {
            dist: {
                options: {
                    style: 'expanded',
                },
                files: {
                    '/home/mark/htdocs/the-round/httpdocs/wp-content/themes/the-round/style.css': '/home/mark/htdocs/the-round/sass/styles.scss',
                    // '<%= vars.theme_path %>/<%= vars.theme_name %>/style-custom-login.css': 'sass/custom-login-styles.scss',
                }
            }
        },

        // Shell
        shell: {
            exp: {
                command: [
                    'cd bin/scripts',
                    './local-export.sh',
                    'cd ../..'
                ].join('&&')
            },
            imp: {
                command: [
                    'cd bin/scripts',
                    './local-import.sh',
                    'cd ../..'
                ].join('&&')
            },
            import_production_db: {
                command: '~/htdocs/criado-em-sampa/bin/wp-db-import',
            },
            project_stats: {
                command: 'du -sh ~/htdocs/criado-em-sampa/httpdocs',
            },
            build_stats: {
                command: 'du -sh ~/htdocs/criado-em-sampa/release',
            }          
        },

        // Version
        version: {
            bower: {
                options: {
                   prefix: '"version"\\:\\s"'
                },
                src: [ 'bower.json' ],
            },
            css: {
                options: {
                   prefix: 'Version\\:\\s'
                },
                src: [ 
                    'sass/styles.scss',

                    // Edit the version directly in the generated CSS file.
                    // Avoids having to run the Sass task just for this. 
                    '<%= vars.theme_path %>/<%= vars.theme_name %>/style.css', 
                ],
            },
            theme: {
                options: {
                   prefix: 'Version\\:\\s'
                },
                src: [ 
                    '<%= vars.theme_path %>/<%= vars.theme_name %>/theme-version.php',
                ],
            },
            readme: {
                options: {
                    prefix: 'Version\ \s*'
                },
                src: [ '<%= rdm %>' ],
            },
            plugin: {
                options: {
                prefix: 'Version\\:\\s'
                },
                src: [ '<%= vars.plugin_path %>/<%= vars.plugin_name %>/<%= vars.plugin_name %>.php' ],
           },           
        },

        // watch for changes and trigger sass, jshint, uglify and livereload
        watch: {
            sass: {
                files: ['sass/**/*.{scss,sass}'],
                tasks: [
                        'sass', 
                        'autoprefixer',
                        'shell:project_stats'
                    ]
            },
            js: {
                files: '<%= jshint.all %>',
                tasks: [
                    'jshint',
                    'shell:project_stats'
                ]
            },
            img: {
                files: ['<%= vars.theme_path %>/<%= vars.theme_name %>/assets/images/src/*.{png,jpg,jpeg,gif,webp,svg}'],
                tasks: [
                    'newer:imagemin:dist',
                    'shell:project_stats'
                ]
            },
            livereload: {
                options: { livereload: true },
                files: [

                    // Gruntfile
                    'Gruntfile.js',

                    // Theme files
                    '<%= vars.theme_path %>/<%= vars.theme_name %>/**/*.php', 
                    '<%= vars.theme_path %>/<%= vars.theme_name %>/lib/**/*.php',
                    '<%= vars.theme_path %>/<%= vars.theme_name %>/style.css', 
                    '<%= vars.theme_path %>/<%= vars.theme_name %>/assets/js/src/**/*.js', 
                    '<%= vars.theme_path %>/<%= vars.theme_name %>/assets/images/dist/**/*.{png,jpg,jpeg,gif,webp,svg}',

                    // Plugin files
                    '<%= vars.plugin_path %>/<%= vars.plugin_name %>/**/*',

                ]
            }
        }

    });

    /**
    *
    * Register tasks
    *
    */

    grunt.registerTask('default', [
		// 'sass',
        // 'imagemin:dist',
        'autoprefixer', 
		'modernizr',
        // 'jshint',        
        'shell:project_stats',		
		'watch',
	]);

    grunt.registerTask( 'bump-minor', [
        'bump-only:minor',
        'version', 
        'bump-commit',        
    ]);

    grunt.registerTask( 'bump-patch', [
        'bump-only:patch',
        'version', 
        'bump-commit',        
    ]);

    // Build Task
    grunt.registerTask('build', [

        // Start with a clean release dir
        // If required, legacy releases can be rebuild based on their git tag
        // and running this task

        'clean:dir_release', 

        // NOTE
        // This task does not automatically bump the version
        // Precede with grunt bump-{minor|patch} to change the version across the project

        // Compile styles
        // Do this because if you haven't run grunt after switching to this branch, 
        // the CSS won't have been updated!
        // 'sass',

        // Make a copy of files for upload to the server

        /***
         *
         * We copy the dirs first so we can add the version to the zipped dir and
         * remove some files we don't want.
         *
         */

        'copy:theme',
        'copy:plugin',

        // Create an archive from the copies
        'compress',

        // Show the archive sizes
        'shell:build_stats', 

        // Delete the uncompressed copies
        'clean:copy_plugin', 
        'clean:copy_theme', 

    ]);
	
	// Copy assets 
	grunt.registerTask('copyassets', [
		'copy:font_awesome',
        'copy:deploy_scripts'       
	]);	

    // Export entire WP site for deployment
    grunt.registerTask('export', [
        'shell:exp'
    ]); 

    // Import entire WP site for local development
    grunt.registerTask('import', [
        'shell:imp'
    ]); 

    // Import production DB for local development
    grunt.registerTask('import-db', [
        'shell:import_production_db'
    ]); 

};
Ejemplo n.º 11
0
module.exports = function(grunt) {
    grunt.initConfig({
        clean: {
            dist: {
                src: ['dist/']
            }
        },

        useminPrepare: {
            options: {
                dest: 'dist'
            },
            html: {
                src: ['./*.html']
            }
        },

        copy: {
            html: {
                files: [
                    {
                        expand: true,
                        cwd: './',
                        src: ['*.html'],
                        dest: 'dist'
                    }
                ]
            }
        },

        imagemin: {
            options: {
                optimizationLevel: 3,
                use: [mozjpeg()]
            },
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: 'img/',
                        src: ['**/*.{png,jpg,gif}'],
                        dest: 'dist/img/'
                    }
                ]
            }
        },

        rev: {
            dist: {
                options: {
                    algorithm: 'sha1',
                    length: 6
                },
                src: [
                    'dist/js/**/*.js',
                    'dist/css/**/*.css',
                    'dist/img/**/*.{jpg,jpeg,png,gif}'
                ]
            }
        },

        usemin: {
            html: ['dist/*.html', 'dist/css/**/*.css']
        }
    });

    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-imagemin');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-rev');
    grunt.loadNpmTasks('grunt-usemin');

    grunt.registerTask('default', function() {
        grunt.task.run('clean');
        grunt.task.run('copy:html');
        grunt.task.run('useminPrepare');
        grunt.task.run('imagemin');
        grunt.task.run('concat:generated');
        grunt.task.run('uglify:generated');
        grunt.task.run('cssmin:generated');
        grunt.task.run('rev');
        grunt.task.run('usemin');
    });
};
Ejemplo n.º 12
0
module.exports = function(grunt) {

  var cssFiles = {
            "<%= pkg.outputFolder %>css/layout.min.css":     ["<%= pkg.outputFolder %>css/layout.less"],
            "<%= pkg.outputFolder %>css/content.min.css":    ["<%= pkg.outputFolder %>css/content.less"],
            "<%= pkg.outputFolder %>css/navigation.min.css": ["<%= pkg.outputFolder %>css/navigation.less"],
            "<%= pkg.outputFolder %>css/print.min.css":      ["<%= pkg.outputFolder %>css/print.less"]
  };

  var jsFiles = {
            "<%= pkg.outputFolder %>js/page.min.js": ["<%= pkg.outputFolder %>js/page.js"]
  };
  
  var cleanFiles = [
            '<%= pkg.outputFolder %>**/*.less',
            '<%= pkg.outputFolder %>**/*.js',
            '<%= pkg.outputFolder %>**/*.xcf',
			'<%= pkg.outputFolder %>**/*.psd',
			'<%= pkg.outputFolder %>**/*.ai',
            '!<%= pkg.outputFolder %>**/*.min.js',
 ];

 var cssBanner = '/*!css <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'+
                 '/*!css <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n';
 
 var jsBanner = '/*!js <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'+
                '/*!js <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n';
 
 var lessVars = {
            color0: 'fff',
			color1: '000'
 };
 
 var mozjpeg = require('imagemin-mozjpeg');

 
  grunt.initConfig({
	
    pkg: grunt.file.readJSON('package.json'),

    copy:{
      default:{
        files:[
            { expand:true, cwd: '<%= pkg.inputFolder %>', src: ['**/*'], dest: '<%= pkg.outputFolder %>' }
        ]
      },
    },

    less:{
        options: {
          paths: ["assets/css"],
		  banner: cssBanner,
		  modifyVars: lessVars
        },
      dev: {
        options: {
          cleancss: false,
          compress: false
        },
        files: cssFiles
      },
      prod: {
          options: {
            cleancss: true,
            compress: true
          },
          files: cssFiles
        }        
    },

    csslint:{
        dev: {
            src: ['<%= pkg.outputFolder %>**/*.css']
        },
    },

    preprocess:{
        default:{
            options: {
                inline:true,
                context : {
                    DEBUG: true
                }
            },
            src : [
                '<%= pkg.outputFolder %>**/*.js'
            ]
        }
    },

    jslint:{
        dev:{
            src : [
                '<%= pkg.outputFolder %>js/*.js',
                '<%= pkg.outputFolder %>js/*.html'
            ]
        }
    },

    jasmine: {
      pivotal: {
        src: '<%= pkg.outputFolder %>js/*.js',
        options: {
          specs: 'test/*Spec.js',
          helpers: 'test/*Helper.js'
        }
      }
    },

    uglify: {
      options: {
        banner: jsBanner
      },
      default: {
        options: {
          mangle: true,
          compress: false,
          beautify: true,
		  use: [mozjpeg()]
        },
          files: jsFiles
      },
    },

    imagemin: {
      options: {
        optimizationlevel:7,
        interlaced:true,
        progressive:true,
        svgoPlugins: [{ removeViewBox: false }],
        use: [mozjpeg()]
      },
      default: {
        files: [{
          expand: true,
          cwd: '<%= pkg.inputFolder %>',
          src: ['**/*.{png,jpg,jpeg,gif}'],
          dest: '<%= pkg.outputFolder %>'
        }]
      }
    },
	
    clean: {
      default: {
        src : cleanFiles
      },
    }


	
  });

  // Load the plugin that provides the "uglify" task.
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-csslint');
  grunt.loadNpmTasks('grunt-preprocess');
  grunt.loadNpmTasks('grunt-jslint');
  grunt.loadNpmTasks('grunt-contrib-jasmine');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-imagemin');
  grunt.loadNpmTasks('grunt-newer');

  // Default task(s).
  grunt.registerTask('dev', ['copy', 'less:dev', 'csslint:dev',
                             'preprocess', 'uglify', 'clean' ]);
  
  grunt.registerTask('prod', ['copy', 'less:prod',
                              'preprocess', 'uglify', 'imagemin:default',
							  'clean' ]);

};
Ejemplo n.º 13
0
       loader: 'file-loader',
       options: { name: mediaOutput },
     },
   ],
 },
 {
   test: /\.jpe?g$|\.png$/,
   use: [
     {
       loader: 'file-loader',
       options: { name: mediaOutput },
     },
     {
       loader: 'img-loader',
       options: {
         plugins: [mozjpeg({ progressive: true }), optipng({})],
       },
     },
   ],
 },
 {
   test: /\.scss$/,
   exclude: /styleguide\.scss$/,
   use: [MiniCssExtractPlugin.loader, ...scssLoaders],
 },
 {
   test: /styleguide\.scss$/,
   use: [
     {
       loader: MiniCssExtractPlugin.loader,
       options: {
Ejemplo n.º 14
0
module.exports = function(grunt) {

  var mozjpeg = require('imagemin-mozjpeg');

  
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    sass: {
      options: {
        includePaths: ['bower_components/foundation/scss']
      },
      dist: {
        options: {
          outputStyle: 'compressed'
        },
        files: {
          'styles/bolt-v20.css': 'scss/bolt-v20.scss'
        }        
      }
    },

    watch: {
      grunt: { files: ['Gruntfile.js'] },

      sass: {
        files: 'scss/**/*.scss',
        tasks: ['sass']
      }
    },

    imagemin: {
      static: {
        options: {
          optimizationLevel: 3,
          svgoPlugins: [{ removeViewBox: false }],
          use: [ mozjpeg()]
        },
      },
      dynamic: {                         
        files: [{
          expand: true,
          cwd: 'images/src/',
          src: ['**/*.{png,jpg,gif}'],
          dest: 'images/optimized/'
        }]
      }
    }


  });

  grunt.loadNpmTasks('grunt-sass');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-imagemin');

  grunt.registerTask('build', ['sass']);
  grunt.registerTask('default', ['build','watch']);
  // optimize images
  grunt.registerTask('images', ['imagemin']);
}
Ejemplo n.º 15
0
module.exports = function(grunt) {
    'use strict';
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        /**
         * Minimize images
         * @link https://github.com/gruntjs/grunt-contrib-imagemin
         * @link https://github.com/imagemin/imagemin-mozjpeg
         */
        imagemin: {                                 // Task
            dynamic: {                              // Another target
                options: {                          // Target options
                    use: [mozjpeg()]
                },
                files: [{
                    expand: true,                   // Enable dynamic expansion
                    cwd: 'src/',                    // Src matches are relative to this path
                    src: ['img/*.{png,jpg,gif}'],   // Actual patterns to match
                    dest: 'dest/'                   // Destination path prefix
                }]
            },
        },

        /**
         * Minimize JavaScript
         * @link https://github.com/gruntjs/grunt-contrib-uglify
         */
        uglify: {
            dist: {
                files: {
                    'src/js/script.min.js': [
                        bootstrap + 'js/transition.js',
                        bootstrap + 'js/alert.js',
                        bootstrap + 'js/button.js',
                        bootstrap + 'js/carousel.js',
                        bootstrap + 'js/collapse.js',
                        bootstrap + 'js/dropdown.js',
                        bootstrap + 'js/modal.js',
                        bootstrap + 'js/tooltip.js',
                        bootstrap + 'js/popover.js',
                        bootstrap + 'js/scrollspy.js',
                        bootstrap + 'js/tab.js',
                        bootstrap + 'js/affix.js',
                        'src/js/src/script.js'
                    ],
                    'dest/js/script.min.js': [
                        bootstrap + 'js/transition.js',
                        bootstrap + 'js/alert.js',
                        bootstrap + 'js/button.js',
                        bootstrap + 'js/carousel.js',
                        bootstrap + 'js/collapse.js',
                        bootstrap + 'js/dropdown.js',
                        bootstrap + 'js/modal.js',
                        bootstrap + 'js/tooltip.js',
                        bootstrap + 'js/popover.js',
                        bootstrap + 'js/scrollspy.js',
                        bootstrap + 'js/tab.js',
                        bootstrap + 'js/affix.js',
                        'src/js/src/script.js'
                    ],                  
                }
            }
        },

        /**
         * Compile Bootstrap
         * @link https://github.com/gruntjs/grunt-contrib-less
         */
        less: {
            development: {
                options: {
                    compress: false, // Se voglio minificare imposto su true
                    yuicompress: true,
                    optimization: 2
                },
                files: {
                    'src/css/src/bootstrap.css': [
                        bootstrap + 'less/bootstrap.less'
                        ],
                  }
            }
        },

        /**
         * Minify CSS
         * @link https://github.com/gruntjs/grunt-contrib-cssmin
         */
        cssmin: {
            options: {

            },
            // dest: {
            //     files: {
            //         'dest/css/style.min.css': [
            //                         'src/css/src/bootstrap.css',
            //                         'src/css/src/style.css'
            //                         ]
            //     }
            // },
            src: {
                files: [{
                    expand: true,
                    cwd: 'src/css/src',
                    src: ['*.css', '!*.min.css'],
                    dest: 'src/css',
                    ext: '.min.css'
                }]
            },
            dest: {
                files: [{
                    expand: true,
                    cwd: 'src/css/src',
                    src: ['*.css', '!*.min.css'],
                    dest: 'dest/css',
                    ext: '.min.css'
                }]
            },
        },

        /**
         * Minify HTML
         * @link https://github.com/gruntjs/grunt-contrib-htmlmin
         * @link https://github.com/kangax/html-minifier#options-quick-reference
         * @link https://github.com/jakubpawlowicz/clean-css#how-to-use-clean-css-programmatically
         */
        htmlmin: {                                              // Task
            dist: {                                             // Target
                options: {                                      // Target options
                    removeComments: true,
                    collapseWhitespace: true,
                    minifyJS: true,
                    minifyCSS: true
                },
                files: {                                        // Dictionary of files
                    'dest/index.html': 'src/index.html',        // 'destination': 'source'
                }
            },
        },

        /**
         * Watch tasks
         * @link https://github.com/gruntjs/grunt-contrib-watch
         */
        watch: {
            img:{
                files: ['src/img/*.{jpg,png,gif}'],
                tasks: ['imagemin'],
            },
            // less: {
            //     files: ['**/*.less'],
            //     tasks: ['yourtask'],
            // },
            // compass: {
            //     files: ['src/css/src/*.{scss,sass}'],
            //     tasks: ['yourtask'],
            // },
            css: {
                files: ['src/css/src/*.css'],
                tasks: ['cssmin'],
            },
            js: {
                files: ['src/js/src/*.js'],
                tasks: ['uglify'],
            },
            html: {
                files: ['src/*.html'],
                tasks: ['htmlmin'],
            },
            options: {
                livereload: 9001,
            },
        },

    });

    grunt.loadNpmTasks('grunt-contrib-imagemin');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-htmlmin');
    grunt.loadNpmTasks('grunt-contrib-watch');


    grunt.registerTask('build', [
                                'less',
                                // 'compass',
                                'cssmin',
                                'imagemin',
                                'uglify',
                                'htmlmin'
                                ]);

    // grunt.registerTask('prova', [
    //                             'uglify:prova',
    //                             'cssmin',
    //                             // 'uglify',
    //                             ]);

    grunt.event.on('watch', function(action, filepath) {
      grunt.log.writeln(filepath + ' has ' + action);
    });

};
Ejemplo n.º 16
0
   }),
   new ImageminPlugin({
     disable: DEV_MODE,
     pngquant: {
       quality: '65-90',
       speed: 4
     },
     svgo: {
       plugins: [
         { removeViewBox: false },
         { removeUselessStrokeAndFill: false }
       ]
     },
     plugins: [
       imageminMozjpeg({
         quality: 100
       })
     ]
   })
 ],
 module: {
   preLoaders: [
     {
       test: /\.js$/,
       loader: 'eslint',
       exclude: /node_modules/
     }
   ],
   loaders: [
     {
       test: /\.js$/,
Ejemplo n.º 17
0
module.exports = function(grunt) {

    var mozjpeg = require('imagemin-mozjpeg');

    // Project configuration.
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        uglify: {
            options: {
                banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
            },
            build: {
                files: [{
                    expand: true,
                    cwd: 'src/js',
                    src: '**/*.js',
                    dest: 'build/js'
                }]
            }
        },
        cssmin: {
            options: {
                keepSpecialComments: 0
            },
            minify: {
                expand: true,
                cwd: 'src/css/',
                src: '*.css', //src: ['*.css', '!*.min.css'],
                dest: 'build/css/'
            }
        },
        htmlmin: {
            dynamic: {
                options: {
                    removeComments: true,
                    collapseWhitespace: true
                },
                files: [{
                    expand: true,
                    cwd: 'src',
                    src: '**/*.html',
                    dest: 'build'
                }]
            }
        },
        imagemin: {
            dynamic: { // Another target
                options: { // Target options
                    optimizationLevel: 7,
                    use: [mozjpeg()]
                },
                files: [{
                    expand: true, // Enable dynamic expansion
                    cwd: 'src/images', // Src matches are relative to this path
                    src: ['**/*.{jpg,png,gif}'], // Actual patterns to match
                    dest: 'build/images' // Destination path prefix
                }]
            }
        }
    });

    // 加载包含 "uglify" 任务的插件。
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-htmlmin');
    grunt.loadNpmTasks('grunt-contrib-imagemin');

    // 默认被执行的任务列表。
    grunt.registerTask('default', ['uglify', 'cssmin', 'htmlmin', 'imagemin']);
};
Ejemplo n.º 18
0
module.exports = function(grunt) {

  'use strict';

  require('time-grunt')(grunt);

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    connect: {
      server: {
        options: {
          port: 1337,
        }
      }
    },

    watch: {
      css: {
        files: 'assets/dev/scss/**/*.scss',
        tasks: ['sass:dev'],
        options: {
        atBegin: true,
        interrupt: true,
        spawn: true,
        livereload: true
        }
      }
    },

    sass: {
      dev: {
        options: {
          sourceMap: true,
          outputStyle: 'nested'
        },
        files: {
          'assets/dev/css/style.css' : 'assets/dev/scss/style.scss'
        }
      },
      prod: {
        options: {
          sourceMap: false,
          outputStyle: 'compressed'
        },
        files: {
          'assets/prod/css/style.css' : 'assets/dev/scss/style.scss'
        }
      }
    },

    uglify: {
      my_targets: {
        files: {
          'assets/prod/js/minified.js': ['assets/dev/js/*.js']
        }
      }
    },

    phantomcss: {
      options: { mismatchTolerance: 0.05 },

      viewportSmall: {
        options: {
          screenshots: 'css-regression-tests/viewportSmall/baselines',
          results: 'css-regression-tests/viewportSmall/results',
          viewportSize: [375, 667]
        },
        src: [ 'css-regression-tests/phantomcss.js' ]
      },
      // viewportMiddle: {},
      // viewportLarge: {}
    },

    imagemin: {
      options: {
        optimizationLevel: 3,
        progressive: true,
        interlaced: true,
        use: [mozjpeg()]
      },
      png: {
        files: [{
          expand: true,
          cwd: 'assets/dev/',
          src: ['images/png/**/*.png'],
          dest: 'assets/prod/'
        }]
      },
      jpg: {
        files: [{
          expand: true,
          cwd: 'assets/dev/',
          src: ['images/jpg/**/*.jpg'],
          dest: 'assets/prod/',
        }]
      },
      gif: {
        files: [{
          expand: true,
          cwd: 'assets/dev/',
          src: ['images/gif/**/*.gif'],
          dest: 'assets/prod/'
        }]
      }
    }
  });

  //TODO: usemin, image optimization,
  grunt.loadNpmTasks('grunt-sass');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-phantomcss');
  grunt.loadNpmTasks('grunt-contrib-imagemin');

  grunt.registerTask('default',[
    'connect',
    'watch'
  ]);

  grunt.registerTask('build',[
    'uglify',
    'sass:prod'
  ]);

  grunt.registerTask('regression-test', [
    'connect',
    'phantomcss'
  ]);

  grunt.registerTask('optimize-images', [
    'imagemin'
  ]);

  grunt.registerTask('optimize-png', [
    'imagemin:png'
  ]);

  grunt.registerTask('optimize-jpg', [
    'imagemin:jpg'
  ]);

  grunt.registerTask('optimize-gif', [
    'imagemin:gif'
  ]);
};
Ejemplo n.º 19
0
gulp.task('imagemin',function(){
  gulp.src('client/src/img/*')
    .pipe(imagemin({use:[imageminMozjpeg({quality:80,quantTable:3})]}))
    .pipe(gulp.dest('client/dist/img/'));
});
Ejemplo n.º 20
0
module.exports = function (grunt) {

  // Run all dependencies that starts with "grunt-"
  require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
  require('time-grunt')(grunt);

  var mozjpeg = require('imagemin-mozjpeg'),
      config = {
        app : "app",
        dist : "dist"
      };

  // Setup
  grunt.initConfig({
    pkg: grunt.file.readJSON('config.json'),
    config : config,

    // Disable caching of files
    rev : {
      options: {
        encoding: 'utf8',
        algorithm: 'md5',
        length: 5
      },
      assets: {
        files: [{
          src: [
            '<%= config.app %>/*.json',
            '<%= config.app %>/assets/images/*.{png,jpg,jpeg,gif}',
            '<%= config.app %>/js/*.js',
            '<%= config.app %>/css/*.css',
            '<%= config.dist %>/js/*.js',
            '<%= config.dist %>/css/*.css'
          ]
        }]
      }
    },

    // SASS compilation
    sass : {
      bootstrap : {
        options: {
          includePaths: ['bower_components/bootstrap-sass/assets/stylesheets'],
          outputStyle: 'expanded'
        },
        files : {
          '<%= config.app %>/css/bootstrap.css': '<%= config.app %>/scss/bootstrap.scss'
        }
      },
      app : {
        files: {
          '<%= config.app %>/css/app.css': '<%= config.app %>/scss/app.scss'
        }
      }
    },

    // Post process CSS files
    postcss : {
      bootstrap: {
        src: '<%= config.app %>/css/bootstrap.css',
        options : { processors : [require('autoprefixer')({browsers:'last 2 versions'}) ] }
      },

      app: {
        src: '<%= config.app %>/css/app.css',
        options : { processors : [require('autoprefixer')({browsers:'last 2 versions'}) ] }
      },

      dist : {
        src : '<%= config.dist %>/css/*.css',
        options: { processors : [ require('cssnano')() ] }
      }
    },


    handlebars: {
        options: {
            namespace: 'App.Templates',
            processName: function(filePath){
                var pre = new RegExp( '^'+config.app+'\/templates\/');
                return filePath.replace(pre,'').replace(/\.hbs$/,'');
            }
        },
        all: {
            files: {
                '<%= config.app %>/js/templates.js':['<%= config.app %>/templates/**/*.hbs']
            }
        }
    },

    imagemin : {
      options : {
        optimizationLevel : 6,
        svgoPlugins: [{ removeViewBox: false }],
        use: [mozjpeg()]
      },
      dist : {
        files : [{
          expand : true,
          cwd : '<%= config.app %>/assets/images/',
          src : ['**/*.{png,gif,jpg,jpeg}'],
          dest : '<%= config.dist %>/assets/images/'
        }]
      },
      dev : {
        // options : { optimizationLevel : 7 },
        files : [{
          expand : true,
          cwd : '<%= config.app %>/assets/images/',
          src : ['**/*.{png,gif,jpg,jpeg}'],
          dest : '<%= config.build %>/assets/images/'
        }]
      }
    },

    // Copy task
    copy : {
      bootstrap_fonts : {
        files : [
          {
            expand : true,
            cwd : 'bower_components/bootstrap-sass/assets/fonts/',
            src : ['**/*'],
            dest : '<%= config.app %>/fonts/'
          }
        ]
      },
      js : {
        files : [
          {
            expand : true,
            cwd : 'bower_components/bootstrap-sass/assets/javascripts/',
            src : ['bootstrap.min.js'],
            dest : '<%= config.app %>/js/'
          },
          {
            expand : true,
            cwd : 'bower_components/jquery/dist/',
            src : ['jquery.min.js'],
            dest : '<%= config.app %>/js/'
          }
        ]
      },
      html : {
        files : [
          {
            expand : true,
            cwd : '<%= config.app %>/',
            src : ['*.html','fonts/{**/**/*,*}','js/app.js','css/app.css','assets/images/*', '*.json', 'api/*'],
            dest : '<%= config.dist %>/'
          }
        ]
      }
    },

    clean : {
      dist : { src : ['<%= config.dist %>'] },
      tmp : { src : ['.tmp'] }
    },

    // Usemin
    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare : {
      html : '<%= config.app %>/*.html',
      options : {
        dest : '<%= config.dist %>'
      }
    },

    // Performs rewrites based on rev and the useminPrepare configuration
    usemin: {
        options: {
            assetsDirs: [
                '<%= config.dist %>',
                '<%= config.dist %>/assets/images',
                '<%= config.dist %>/css',
                '<%= config.dist %>/js',
                '<%= config.dist %>/vendor'
            ]
        },
        html: ['<%= config.dist %>/**/*.html'],
        js: ['<%= config.dist %>/js/*.js'],
        css: ['<%= config.dist %>/css/*.css']
    },

    // Express server
    express : {
      all: {
        options: {
          // Set your file directory 
          bases : ['<%= pkg.location %>'],
          port: 9000,
          hostname: "0.0.0.0",
          livereload: true
        }
      }
    },

    // Open Browser
    open : {
      all: {
        path: 'http://localhost/EngageQuiz/app',
        app: 'Chrome'
      }
    },

    // Watch for file changes
    watch : {
      all: {
        files: [
          'Gruntfile.js',
          '<%= config.app %>/*.html',
          '<%= config.app %>/js/*.js',
          '<%= config.app %>/assets/**/*.{jpg,png,gif,jpeg}'
        ],
        options: {
          livereload: true
        }
      },
      boostrap_sass : {
        files : [
          '<%= config.app %>/scss/bootstrap.scss'
        ],
        tasks : ['sass:bootstrap','postcss:bootstrap']
      },
      app_sass : {
        files: [
          '<%= config.app %>/scss/{*,**/*,**/**/*}.scss',
          '!<%= config.app %>/scss/bootstrap.scss'
        ],
        tasks: ['sass:app','postcss:app']
      },
      handlebars: {
          files: ['<%= config.app %>/templates/**/*.hbs'],
          tasks: ['handlebars']
      }
    }
  });
  
  // Developer centric tasks
  grunt.registerTask('dev', 'Build for developers', [
    'build',
    // 'express',
    // 'open',
    'watch'
  ]);

  grunt.registerTask('build', 'Build development environment', [
    'copy:bootstrap_fonts',
    'copy:js',
    'sass',
    'postcss:bootstrap',
    'postcss:app',
    'handlebars'
  ]);

  grunt.registerTask('dist', 'Build for production environment', [
    'clean:dist',
    'build',
    'useminPrepare',
    'copy:html',
    'imagemin:dist',
    'concat:generated',
    'cssmin:generated',
    'uglify:generated',
    'usemin',
    'clean:tmp'
  ]);

  // default task for developers
  grunt.registerTask('default', ['dev']);

};
Ejemplo n.º 21
0
    fonts: destAssetsDir + '/fonts',
    staticjs: destAssetsDir + '/js',
    productionDir: 'static'
  },

  images: {
      progressive: true,
      optimizationLevel: 3,
      svgoPlugins: [
          { removeViewBox: false },               // 3a
          { removeUselessStrokeAndFill: false },  // 3b
          { removeEmptyAttrs: false }             // 3c
      ],
      use: [
        imageminMozjpeg({
          progressive: true,
          quality: 80
        })
      ]
  },

  sass: {
    autoprefixer: {
      // you could use ['last 2 version'] instead of listing out browser specifics
      browsers: [
        'ie >= 10',
        'ie_mob >= 10',
        'ff >= 30',
        'chrome >= 32',
        'safari >= 6',
        'opera >= 23',
        'ios >= 6',
Ejemplo n.º 22
0
// var optimage = require('optimage');
// optimage({ inputFile: "screen.png", outputFile: "screen.min.jpg" }, function(err, res){});

const imagemin = require('imagemin');
const imageminMozjpeg = require('imagemin-mozjpeg');
const imageminPngquant = require('imagemin-pngquant');

imagemin(['./screen.png'], 'build/images', {
    plugins: [
        imageminMozjpeg({targa: true}),
        imageminPngquant({quality: '65-80'})
    ]
}).then(files => {
    console.log(files);
    //=> [{data: <Buffer 89 50 4e …>, path: 'build/images/foo.jpg'}, …]
});
Ejemplo n.º 23
0
'use strict'; // eslint-disable-line

const { default: ImageminPlugin } = require('imagemin-webpack-plugin');
const imageminMozjpeg = require('imagemin-mozjpeg');

const config = require('./config');

module.exports = {
  plugins: [
    new ImageminPlugin({
      optipng: { optimizationLevel: 7 },
      gifsicle: { optimizationLevel: 3 },
      pngquant: { quality: '65-90', speed: 4 },
      svgo: {
        plugins: [{ removeUnknownsAndDefaults: false }, { cleanupIDs: false }],
      },
      plugins: [imageminMozjpeg({ quality: 75 })],
      disable: (config.enabled.watcher),
    }),
  ],
};
Ejemplo n.º 24
0
        'public/css/main.css'],
        'public/css/main.min.css'
    )
;

mix.webpackConfig({
    plugins: [
        new BrowserSyncPlugin({
            host: 'localhost',
            port: 3000,
            files: ['public/*.html', 'public/css/*.css', 'public/js/*.js'],
            server: { baseDir: ['public'] }
        }),
        new CopyWebpackPlugin([{
            from: 'src/img',
            to: 'public/img',
        }]),
        new ImageminPlugin({
            test: /\.(jpe?g|png|gif|svg)$/i,
            pngquant: {
                quality: '65-80'
            },
            plugins: [
                imageminMozjpeg({
                    quality: 65,
                })
            ]
        })
    ]
});
Ejemplo n.º 25
0
module.exports = function (grunt) {

  var lrPort = 35729;
  var mozjpeg = require('imagemin-mozjpeg');
  var lrSnippet = require('connect-livereload')({ port: lrPort });
  var lrMiddleware = function(connect, options) {
    return [
      lrSnippet,
      connect.static(options.base[0]),
      connect.directory(options.base[0])
    ];
  };
  require('load-grunt-tasks')(grunt);
  require('time-grunt')(grunt);

  grunt.initConfig({

    clean: {
        tests: ['dist']
    },

    codekit: {
      defaults: {
        options: {},
        files: {
          'dist/': ['app/*.kit']
        }
      },
    },

    imagemin: {                          // Task 
      static: {                          // Target 
        options: {                       // Target options 
          optimizationLevel: 3,
          svgoPlugins: [{ removeViewBox: false }],
          use: [mozjpeg()]
        }
      },
      dynamic: {                         // Another target 
        files: [{
          expand: true,                  // Enable dynamic expansion 
          src: ['src/images/*.{png,jpg,gif}'],   // Actual patterns to match 
        }]
      }
    },

    cssmin: {
      css: {  
        src: 'src/styles/style.css',
        dest: 'src/styles/style.min.css'
      }  
    },

    connect: {
      options: {
        port: 8000,
        hostname: 'localhost',
        base: '.'
      },
      livereload: {
        options: {
          middleware: lrMiddleware
        }
      }
    },

    watch: {
      css: {
        files: ['src/styles/*.scss','app/*','src/images/*.{png,jpg,gif}'],
        tasks: ['sass','cssmin','codekit','imagemin'],
        options: {
          livereload: true,
          spawn: false,
        }
      },
      client: {
        options: {
          livereload: lrPort
        },
        files: ['dist/*.html', 'src/styles/*', 'src/scripts/*', 'src/images/*']
      }
    },

    sass: {
      options: {
        sourceMap: false
      },
      dist: {
        files: {
          'src/styles/style.css': 'src/styles/style.scss'
        }
      }
    }


  });

  grunt.loadTasks('tasks');

  grunt.registerTask('test', ['clean', 'codekit']);
  grunt.registerTask('default', ['codekit','cssmin','imagemin','watch']);
};
Ejemplo n.º 26
0
  module.exports = function (grunt) {
    // Apparently I have to require mozjpeg anyways
    // need to research why. Is it because it's not
    // seen as a grunt package?
    var mozjpeg = require('imagemin-mozjpeg');
    // require time-grunt at the top and pass in the grunt instance
    // it will measure how long things take for performance
    //testing
    require('time-grunt')(grunt);

    // load-grunt will read the package file and automatically
    // load all our packages configured there.
    // Yay for laziness
    require('load-grunt-tasks')(grunt);

    grunt.initConfig({

      // Reference to the package file
      pkg: grunt.file.readJSON('package.json'),

      // JAVASCRIPT TASKS
      // Hint the grunt file and all files under js/
      // and one directory below
      jshint: {
        files: [ 'Gruntfile.js', 'js/{,*/}*.js'],
        options: {
          reporter: require('jshint-stylish')
          // options here to override JSHint defaults
        }
      },

      // Takes all the files under js/ and concatenates
      // them together. I've chosen not to mangle the compressed file
      uglify: {
        main: {
          options: {
            mangle: false,
            sourceMap: true,
            banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
            '<%= grunt.template.today("yyyy-mm-dd") %> ' +
            'Released under the MIT license http://caraya.mit-license.org/*/'
          },
          files: {
            'js/build.js': [ 'js/*.js' ],
          }
        },
        libs: {
          options: {
            mangle: false,
            sourceMap: true
          },
          files: {
            'lib/vendor/allLibs.js': [
              'lib/vendor/*.js',
              '!lib/vendor/modernizr-2.8.3.min.js' ],
          }
        },
        plugins: {
          options: {
            mangle:false,
            sourceMap: true
          },
          files: {
            'lib/plugins/allPlugs.js': [ 'lib/plugins/*.js' ]
          }
        }
      },


      // OPTIONAL JS TASKS
      // Both Coffescript and Babel will generate Javascript files.
      // May want to run them before concat and uglify to make sure we
      // have all our files ready to be processed.
      // If you're using either Babel or Coffeescript run the corresponding
      // task below

      // COFFEESCRIPT
      // If you want to use coffeescript (http://coffeescript.org/)
      // change the cwd value to the locations of your coffee files
      coffee: {
        files: {
          expand: true,
          flatten: true,
          cwd: 'coffee',
          src: ['*.coffee'],
          dest: 'js/',
          ext: '.js'
        }
      },

      // BABEL
      // Babel allows you to transpile ES6 to current ES5 without needing
      // a plugin or anything installed in your application. This will
      // eventually go away when I'm happy with ES6 support in browsers
      // See http://babeljs.io/ for more information.
      babel: {
        options: {
          sourceMap: true
        },
        dist: {
          files: {
            'es6/*.js': 'src/*.js'
          }
        }
      },

      // SASS AND CSS RELATED TASKS
      // Converts all the files under scss/ ending with .scss
      // into the equivalent css file on the css/ directory
      sass: {
        dev: {
          options: {
            style: 'expanded'
          },
          files: [ {
            expand: true,
            cwd: 'sass',
            src: [ '*.scss'],
            dest: 'css',
            ext: '.css'
          }]
        },
        production: {
          options: {
            style: 'compress'
          },
          files: [ {
            expand: true,
            cwd: 'sass',
            src: [ '*.scss'],
            dest: 'css',
            ext: '.css'
          }]
        }
      },

      // This task requires the scss-lint ruby gem to be
      // installed on your system If you choose not to
      // install it, comment out this task and the prep-css
      // and work-lint tasks below
      //
      // I've chosen not to fail on errors or warnings.
      scsslint: {
        allFiles: [
          'scss/*.scss',
          'scss/modules/_mixins.scss',
          'scss/modules/_variables.scss',
          'scss/partials/*.scss'],
        options: {
          force: true,
          colorizeOutput: true
        }
      },

      // Optional CSS Post Process
      // Autoprefixer will check caniuse.com's database and
      // add the necessary prefixes to CSS elements as needed.
      // This saves us from doing the work manually
      autoprefixer: {
        options: {
          browsers: [
            'ie >= 10',
            'ie_mob >= 10',
            'ff >= 30',
            'chrome >= 34',
            'safari >= 7',
            'opera >= 23',
            'ios >= 7',
            'android >= 4.4',
            'bb >= 10'
          ]
        },

        files: {
          expand: true,
          flatten: true,
          src: 'css/*.css',
          dest: 'css/*.css'
        }
      },

      // UNCSS will analyzes the your HTML pages and
      // remove from the CSS all the classes that are
      // not used in any of your HTML pages
      //
      // This task needs to be run in the processed CSS
      // rather than the SCSS files
      //
      //See https://github.com/addyosmani/grunt-uncss
      // for more information
      uncss: {
        dist: {
          files: {
            'dist/css/main.css': [ 'dist/*.html' ]
          }
        }
      },

      imagemin: {
        png: {
          options: {
            optimizationLevel: 7
          },
          files: [
            {
              // Set to true to enable the following options…
              expand: true,
              // cwd is 'current working directory'
              cwd: 'images/',
              src: ['**/*.png'],
              // Could also match cwd line above. i.e. project-directory/img/
              dest: 'dist/images/',
              ext: '.png'
            }
          ]
        },
        jpg: {
          options: {
            progressive: true,
            use: [mozjpeg()]
          },
          files: [
            {
              // Set to true to enable the following options…
              expand: true,
              // cwd is 'current working directory'
              cwd: 'images/',
              src: ['**/*.jpg'],
              // Could also match cwd. i.e. project-directory/img/
              dest: 'dist/images/',
              ext: '.jpg'
            }
          ]
        }
      },

      // GH-PAGES TASK
      // Push the specified content into the repositories
      // gh-pages branch
      'gh-pages': {
        options: {
          message: 'Content committed from Grunt gh-pages',
          dotfiles: true,
          base: 'dist/'
        },
        // These files will get pushed to the `
        // gh-pages` branch (the default)
        src: ['**/*']
      },

      // FILE MANAGEMENT
      // Can't seem to make the copy task create the directory
      // if it doesn't exist so we go to another task to create
      // the fn directory
      mkdir: {
        build: {
          options: {
            create: [ 'dist' ]
          }
        }
      },

      // Copy the files from our repository into the dist
      // directory. Do not do deep copy of HTML files.
      // It'll copy stuff that we keep around for testing,
      // like the webfont loader docs. Either delete the
      // webfont loader stuff or just copy html from the
      // top level directory (which I changed it to do)
      copy: {
        dist: {
          files: [ {
            expand: true,
            src: [
              'fonts/**/*',
              'css/**/*',
              'lib/**/*',
              'js/**/*',
              '*.html'],
            dest: 'dist/'
          }]
        }
      },

      // Clean the build directory
      clean: {
        all: [ 'dist/' ]
      },

      perfbudget: {
        all: {
          options: {
            url: 'https://caraya.github.io/books-as-apps/typography.html',
            key: 'A.be974c9b235f69677db80813612925c6',
            budget: {
              visualComplete: '4000',
              SpeedIndex: '1500'
            }
          }
        }
      },

      critical: {
        typography: {
          options: {
            minify: true,
            base: './',
            css: [
              'css/main.css'
            ],
            width: 1200,
            height: 800
          },
          src: 'typography.html',
          dest: 'dist/typography.html'
        }
      },


      // Compare the size of the listed files
      compare_size: {
        files: [
          'dist/js/*.js',
          'dist/css/*.css'
        ],
        options: {
          // Location of stored size data
          cache: '.sizecache.json',

          // Compressor label-function pairs
          compress: {
            gz: function (fileContents) {
              return require('gzip-js').zip(fileContents, {}).length;
            }
          }
        }
      }



    });
    // closes initConfig

    // CUSTOM TASKS
    // Usually a combination of one or more tasks defined above

    grunt.task.registerTask(
      'lint',
      [ 'jshint' ]
    );

    grunt.task.registerTask(
      'publish',
      [ 'clean:all', 'copy:dist', 'imagemin', 'gh-pages' ]
    );
    grunt.task.registerTask(
      'lint-all',
      [ 'scsslint', 'jshint']
    );

    // Prep CSS starting with SASS, autoprefix et. al
    grunt.task.registerTask(
      'prep-css',
      [ 'scsslint', 'sass:dev', 'autoprefixer' ]
    );

    grunt.task.registerTask(
      'optional-js',
      [ 'coffeescript', 'babel' ]
    );

    grunt.task.registerTask(
      'prep-js',
      [ 'jshint', 'concat:dist', 'uglify' ]
    );

    grunt.task.registerTask(
      'all-js',
      [' optional-js', 'prep-js' ]
    );

  };