Skip to content

Commit

Permalink
add grunt command-line tools for building, watching and linting.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcgee committed Oct 26, 2015
1 parent f1d91cb commit bc8da5a
Show file tree
Hide file tree
Showing 2 changed files with 167 additions and 46 deletions.
189 changes: 149 additions & 40 deletions gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,151 @@
module.exports = function(grunt){

grunt.initConfig({

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

watch: {
options: {
livereload: true
}
},

connect: {
dev: {
options: {
//port: '?',
port: '62332',
base: '',
hostname: '*'
//open: ''
//open: '//localhost:50390/node_modules/intern/client.html',
//open: true
}
}
},
open: {
dev: {
path: 'http://localhost:62332/tests/Export/index.html'
}
}
});


// load the tasks
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-open');

// define the tasks
grunt.registerTask('dev', ['connect:dev', 'open:dev', 'watch']);
/* global module */
module.exports = function (grunt) {
'use strict';

// grunt task config
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
tag: {
banner: '/* <%= pkg.name %>\n' +
' * version <%= pkg.version %>\n' +
' * Project: <%= pkg.homepage %>\n' +
' */\n'
},
copy: {
build: {
src: ['**', '!cmv/**', '!node_modules/**', '!tests/**', '!package.json', '!gruntfile.js'],
dest: 'dist',
expand: true
}
},
clean: {
build: {
src: ['dist']
}
},
autoprefixer: {
build: {
expand: true,
cwd: 'dist/widgets',
src: ['widgets/**/*.css'],
dest: 'dist/widgets'
}
},
cssmin: {
build: {
expand: true,
cwd: 'dist',
src: ['**/*.css'],
dest: 'dist'
}
},

csslint: {
build: {
src: ['widgets/**/*.css'],
options: {
csslintrc: '.csslintrc'
}
}
},

eslint: {
build: {
src: ['widgets/**/*.js', 'config/**/*.js'],
options: {
eslintrc: '.eslintrc'
}
}
},

uglify: {
build: {
files: [{
expand: true,
cwd: 'dist',
src: ['**/*.js', '!**/config/**', '!**/cmv/**'],
dest: 'dist',
ext: '.js'
}],
options: {
banner: '<%= tag.banner %>',
sourceMap: true,
sourceMapIncludeSources: true,
compress: {
'drop_console': false
}
}
}
},

watch: {
dev: {
files: ['widgets/**'],
tasks: ['eslint', 'csslint']
},
build: {
files: ['widgets/**'],
tasks: ['eslint', 'csslint']
}
},

connect: {
dev: {
options: {
port: 3000,
base: '.',
hostname: '*'
}
},
build: {
options: {
port: 3001,
base: 'dist/viewer',
hostname: '*'
}
}
},
open: {
'dev_browser': {
path: 'http://localhost:3000/index.html'
},
'build_browser': {
path: 'http://localhost:3001/index.html'
}
},
compress: {
build: {
options: {
archive: 'dist/cmv-widgets.zip'
},
files: [{
expand: true,
cwd: 'dist',
src: ['**', '!**/dijit.css']
}]
}
}
});

// load the tasks
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-csslint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-newer');
grunt.loadNpmTasks('grunt-open');
grunt.loadNpmTasks('grunt-contrib-compress');

// define the tasks
grunt.registerTask('default', 'Watches the project for changes, automatically builds them and runs a web server and opens default browser to preview.', ['eslint', 'csslint', 'connect:dev', 'open:dev_browser', 'watch:dev']);
grunt.registerTask('build', 'Compiles all of the assets and copies the files to the build directory.', ['clean', 'copy', 'scripts', 'stylesheets', 'compress:build']);
grunt.registerTask('build-view', 'Compiles all of the assets and copies the files to the build directory starts a web server and opens browser to preview app.', ['clean', 'copy', 'scripts', 'stylesheets', 'compress:build', 'connect:build', 'open:build_browser', 'watch:build']);
grunt.registerTask('scripts', 'Compiles the JavaScript files.', ['eslint', 'uglify']);
grunt.registerTask('stylesheets', 'Auto prefixes css and compiles the stylesheets.', ['csslint', 'autoprefixer', 'cssmin']);
grunt.registerTask('lint', 'Run simple eslint and csslint.', ['eslint', 'csslint']);
};
24 changes: 18 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,25 @@
"author": "Tim McGee",
"license": "",
"year": "2015",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-connect": "0.4.x",
"grunt-contrib-watch": "0.5.x",
"grunt-open": "^0.2.3"
},
"homepage": "https://tmcgee.github.io/cmv-widgets/",
"repository": "https://github.com/tmcgee/cmv-widgets",
"dependencies": {
"csslint": "0.10.x",
"babel-eslint": "4.1.x",
"eslint": "1.7.x",
"grunt": "0.4.x",
"grunt-autoprefixer": "0.7.x",
"grunt-contrib-clean": "0.5.x",
"grunt-contrib-connect": "0.7.x",
"grunt-contrib-copy": "0.5.x",
"grunt-contrib-csslint": "0.5.x",
"grunt-contrib-cssmin": "0.9.x",
"grunt-eslint": "17.3.x",
"grunt-contrib-uglify": "0.4.x",
"grunt-contrib-watch": "0.6.x",
"grunt-newer": "0.7.x",
"grunt-open": "0.2.x",
"grunt-contrib-compress": "0.10.x"
},
"engine": "node >= 0.10"
}

0 comments on commit bc8da5a

Please sign in to comment.