videojs-quality-selector/Gruntfile.js

159 lines
4 KiB
JavaScript
Raw Normal View History

2017-06-21 00:43:49 +00:00
/*
* Copyright (c) 2017 Jeremy Thomerson
* Licensed under the MIT license.
*/
'use strict';
2017-06-22 13:34:19 +00:00
var path = require('path'),
getCodeVersion = require('silvermine-serverless-utils/src/get-code-version');
const sass = require('node-sass');
2017-06-21 00:43:49 +00:00
module.exports = function(grunt) {
2017-06-22 13:34:19 +00:00
var DEBUG = !!grunt.option('debug'),
config;
2017-06-21 00:43:49 +00:00
config = {
js: {
all: [ 'Gruntfile.js', 'src/**/*.js', 'tests/**/*.js' ],
2017-06-22 13:34:19 +00:00
standalone: path.join(__dirname, 'src', 'js', 'standalone.js'),
},
sass: {
base: path.join(__dirname, 'src', 'sass'),
all: [ 'src/**/*.scss' ],
2017-06-21 00:43:49 +00:00
},
2017-06-22 13:34:19 +00:00
dist: {
base: path.join(__dirname, 'dist'),
jsFileName: 'silvermine-videojs-quality-selector',
2017-06-22 13:34:19 +00:00
},
};
config.dist.js = {
bundle: path.join(config.dist.base, 'js', '<%= config.dist.jsFileName %>.js'),
minified: path.join(config.dist.base, 'js', '<%= config.dist.jsFileName %>.min.js'),
2017-06-22 13:34:19 +00:00
};
config.dist.css = {
base: path.join(config.dist.base, 'css'),
all: path.join(config.dist.base, '**', '*.css'),
2017-06-21 00:43:49 +00:00
};
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
2017-06-22 13:34:19 +00:00
versionInfo: getCodeVersion.both(),
config: config,
browserify: {
main: {
src: config.js.standalone,
dest: config.dist.js.bundle,
},
},
uglify: {
main: {
files: {
'<%= config.dist.js.minified %>': config.dist.js.bundle,
},
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> <%= versionInfo %> */\n',
sourceMap: true,
sourceMapIncludeSources: true,
mangle: true,
compress: true,
beautify: false,
},
},
},
sass: {
options: {
implementation: sass,
2017-06-22 13:34:19 +00:00
sourceMap: DEBUG,
indentWidth: 3,
outputStyle: DEBUG ? 'expanded' : 'compressed',
sourceComments: DEBUG,
},
main: {
files: [
{
expand: true,
cwd: config.sass.base,
src: [ '**/*.scss' ],
dest: config.dist.css.base,
ext: '.css',
extDot: 'first',
},
],
},
},
postcss: {
options: {
map: DEBUG,
processors: [
require('autoprefixer')({ browsers: '> .05%' }), // eslint-disable-line global-require
],
},
main: {
src: config.dist.css.all,
},
},
2017-06-21 00:43:49 +00:00
clean: {
dist: config.dist.base,
},
2017-06-21 00:43:49 +00:00
eslint: {
target: config.js.all,
},
2017-06-22 13:34:19 +00:00
sasslint: {
options: {
configFile: path.join(__dirname, 'node_modules', '@silvermine/sass-lint-config', 'sass-lint.yml'),
2017-06-22 13:34:19 +00:00
},
target: config.sass.all,
},
watch: {
grunt: {
files: [ 'Gruntfile.js' ],
tasks: [ 'build' ],
},
js: {
files: [ 'src/**/*.js' ],
tasks: [ 'build-js' ],
},
css: {
files: [ 'src/**/*.scss' ],
tasks: [ 'build-css' ],
},
},
2017-06-21 00:43:49 +00:00
});
2017-06-22 13:34:19 +00:00
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-browserify');
2017-06-21 00:43:49 +00:00
grunt.loadNpmTasks('grunt-eslint');
2017-06-22 13:34:19 +00:00
grunt.loadNpmTasks('grunt-postcss');
grunt.loadNpmTasks('grunt-contrib-clean');
2017-06-22 13:34:19 +00:00
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-sass-lint');
2017-06-21 00:43:49 +00:00
2017-06-22 13:34:19 +00:00
grunt.registerTask('standards', [ 'eslint', 'sasslint' ]);
grunt.registerTask('build-js', [ 'browserify', 'uglify' ]);
grunt.registerTask('build-css', [ 'sass', 'postcss' ]);
grunt.registerTask('build', [ 'build-js', 'build-css' ]);
2017-08-04 18:23:15 +00:00
grunt.registerTask('develop', [ 'build', 'watch' ]);
2017-06-21 00:43:49 +00:00
grunt.registerTask('default', [ 'standards' ]);
};