Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update Gruntfile

  • Loading branch information...
commit d926f994e7a9de4bc26d5f1fda093732315fb210 1 parent 0030a89
@killfill killfill authored
Showing with 269 additions and 147 deletions.
  1. +1 −0  .gitignore
  2. +245 −146 Gruntfile.js
  3. +23 −1 package.json
View
1  .gitignore
@@ -2,3 +2,4 @@
app/scripts/config.js
pkg/build-info
pkg/packlist
+node_modules
View
391 Gruntfile.js
@@ -1,177 +1,276 @@
-module.exports = function( grunt ) {
- 'use strict';
- //
- // Grunt configuration:
- //
- // https://github.com/cowboy/grunt/blob/master/docs/getting_started.md
- //
- grunt.initConfig({
-
- // Project configuration
- // ---------------------
-
- // specify an alternate install location for Bower
- bower: {
- dir: 'app/components'
- },
+'use strict';
+var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
+var mountFolder = function (connect, dir) {
+ return connect.static(require('path').resolve(dir));
+};
- // Coffee to JS compilation
- coffee: {
- compile: {
- files: {
- 'app/scripts/*.js': 'app/scripts/**/*.coffee',
- 'test/spec/*.js': 'test/spec/**/*.coffee'
- }
- }
- },
+module.exports = function (grunt) {
+ // load all grunt tasks
+ require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
- // compile .scss/.sass to .css using Compass
- compass: {
- dist: {
- // http://compass-style.org/help/tutorials/configuration-reference/#configuration-properties
- options: {
- css_dir: 'temp/styles',
- sass_dir: 'app/styles',
- images_dir: 'app/images',
- javascripts_dir: 'temp/scripts',
- force: true
- }
- }
- },
+ // configurable paths
+ var yeomanConfig = {
+ app: 'app',
+ dist: 'dist'
+ };
- // generate application cache manifest
- manifest:{
- dest: ''
- },
+ try {
+ yeomanConfig.app = require('./component.json').appPath || yeomanConfig.app;
+ } catch (e) {}
- // default watch configuration
+ grunt.initConfig({
+ yeoman: yeomanConfig,
watch: {
coffee: {
- files: 'app/scripts/**/*.coffee',
- tasks: 'coffee reload'
+ files: ['<%= yeoman.app %>/scripts/{,*/}*.coffee'],
+ tasks: ['coffee:dist']
+ },
+ coffeeTest: {
+ files: ['test/spec/{,*/}*.coffee'],
+ tasks: ['coffee:test']
},
compass: {
- files: [
- 'app/styles/**/*.{scss,sass}'
- ],
- tasks: 'compass reload'
+ files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
+ tasks: ['compass']
},
- reload: {
+ livereload: {
files: [
- 'app/*.html',
- 'app/styles/**/*.css',
- 'app/scripts/**/*.js',
- 'app/views/**/*.html',
- 'app/images/**/*'
+ '<%= yeoman.app %>/{,*/}*.html',
+ '{.tmp,<%= yeoman.app %>}/styles/{,*/}*.css',
+ '{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
+ '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp}'
],
- tasks: 'reload'
+ tasks: ['livereload']
}
},
-
- // default lint configuration, change this to match your setup:
- // https://github.com/cowboy/grunt/blob/master/docs/task_lint.md#lint-built-in-task
- lint: {
- files: [
- 'Gruntfile.js',
- 'app/scripts/**/*.js',
- 'spec/**/*.js'
- ]
+ connect: {
+ livereload: {
+ options: {
+ port: 9000,
+ // Change this to '0.0.0.0' to access the server from outside.
+ hostname: 'localhost',
+ middleware: function (connect) {
+ return [
+ lrSnippet,
+ mountFolder(connect, '.tmp'),
+ mountFolder(connect, yeomanConfig.app)
+ ];
+ }
+ }
+ },
+ test: {
+ options: {
+ port: 9000,
+ middleware: function (connect) {
+ return [
+ mountFolder(connect, '.tmp'),
+ mountFolder(connect, 'test')
+ ];
+ }
+ }
+ }
+ },
+ open: {
+ server: {
+ url: 'http://localhost:<%= connect.livereload.options.port %>'
+ }
+ },
+ clean: {
+ dist: ['.tmp', '<%= yeoman.dist %>/*'],
+ server: '.tmp'
},
-
- // specifying JSHint options and globals
- // https://github.com/cowboy/grunt/blob/master/docs/task_lint.md#specifying-jshint-options-and-globals
jshint: {
options: {
- curly: true,
- eqeqeq: true,
- immed: true,
- latedef: true,
- newcap: true,
- noarg: true,
- sub: true,
- undef: true,
- boss: true,
- eqnull: true,
- browser: true
+ jshintrc: '.jshintrc'
},
- globals: {
- angular: true
+ all: [
+ 'Gruntfile.js',
+ '<%= yeoman.app %>/scripts/{,*/}*.js'
+ ]
+ },
+ karma: {
+ unit: {
+ configFile: 'karma.conf.js',
+ singleRun: true
}
},
-
- // Build configuration
- // -------------------
-
- // the staging directory used during the process
- staging: 'temp',
- // final build output
- output: 'dist',
-
- mkdirs: {
- staging: 'app/'
+ coffee: {
+ dist: {
+ files: {
+ '.tmp/scripts/coffee.js': '<%= yeoman.app %>/scripts/*.coffee'
+ }
+ },
+ test: {
+ files: [{
+ expand: true,
+ cwd: '.tmp/spec',
+ src: '*.coffee',
+ dest: 'test/spec'
+ }]
+ }
},
-
- // Below, all paths are relative to the staging directory, which is a copy
- // of the app/ directory. Any .gitignore, .ignore and .buildignore file
- // that might appear in the app/ tree are used to ignore these values
- // during the copy process.
-
- // concat css/**/*.css files, inline @import, output a single minified css
- css: {
- 'styles/main.css': ['styles/**/*.css']
+ compass: {
+ options: {
+ sassDir: '<%= yeoman.app %>/styles',
+ cssDir: '.tmp/styles',
+ imagesDir: '<%= yeoman.app %>/images',
+ javascriptsDir: '<%= yeoman.app %>/scripts',
+ fontsDir: '<%= yeoman.app %>/styles/fonts',
+ importPath: '<%= yeoman.app %>/components',
+ relativeAssets: true
+ },
+ dist: {},
+ server: {
+ options: {
+ debugInfo: true
+ }
+ }
},
-
- // renames JS/CSS to prepend a hash of their contents for easier
- // versioning
- rev: {
- js: 'scripts/**/*.js',
- css: 'styles/**/*.css',
- img: 'images/**'
+ concat: {
+ dist: {
+ files: {
+ '<%= yeoman.dist %>/scripts/scripts.js': [
+ '.tmp/scripts/{,*/}*.js',
+ '<%= yeoman.app %>/scripts/{,*/}*.js'
+ ]
+ }
+ }
},
-
- // usemin handler should point to the file containing
- // the usemin blocks to be parsed
- 'usemin-handler': {
- html: 'index.html'
+ useminPrepare: {
+ html: '<%= yeoman.app %>/index.html',
+ options: {
+ dest: '<%= yeoman.dist %>'
+ }
},
-
- // update references in HTML/CSS to revved files
usemin: {
- html: ['**/*.html'],
- css: ['**/*.css']
+ html: ['<%= yeoman.dist %>/{,*/}*.html'],
+ css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
+ options: {
+ dirs: ['<%= yeoman.dist %>']
+ }
},
-
- // HTML minification
- html: {
- files: ['**/*.html']
+ imagemin: {
+ dist: {
+ files: [{
+ expand: true,
+ cwd: '<%= yeoman.app %>/images',
+ src: '{,*/}*.{png,jpg,jpeg}',
+ dest: '<%= yeoman.dist %>/images'
+ }]
+ }
},
-
- // Optimizes JPGs and PNGs (with jpegtran & optipng)
- img: {
- dist: '<config:rev.img>'
+ cssmin: {
+ dist: {
+ files: {
+ '<%= yeoman.dist %>/styles/main.css': [
+ '.tmp/styles/{,*/}*.css',
+ '<%= yeoman.app %>/styles/{,*/}*.css'
+ ]
+ }
+ }
},
-
- // rjs configuration. You don't necessarily need to specify the typical
- // `path` configuration, the rjs task will parse these values from your
- // main module, using http://requirejs.org/docs/optimization.html#mainConfigFile
- //
- // name / out / mainConfig file should be used. You can let it blank if
- // you're using usemin-handler to parse rjs config from markup (default
- // setup)
- rjs: {
- // no minification, is done by the min task
- optimize: 'none',
- baseUrl: './scripts',
- wrap: true
+ htmlmin: {
+ dist: {
+ options: {
+ /*removeCommentsFromCDATA: true,
+ // https://github.com/yeoman/grunt-usemin/issues/44
+ //collapseWhitespace: true,
+ collapseBooleanAttributes: true,
+ removeAttributeQuotes: true,
+ removeRedundantAttributes: true,
+ useShortDoctype: true,
+ removeEmptyAttributes: true,
+ removeOptionalTags: true*/
+ },
+ files: [{
+ expand: true,
+ cwd: '<%= yeoman.app %>',
+ src: ['*.html', 'views/*.html'],
+ dest: '<%= yeoman.dist %>'
+ }]
+ }
+ },
+ cdnify: {
+ dist: {
+ html: ['<%= yeoman.dist %>/*.html']
+ }
+ },
+ ngmin: {
+ dist: {
+ files: [{
+ expand: true,
+ cwd: '<%= yeoman.dist %>/scripts',
+ src: '*.js',
+ dest: '<%= yeoman.dist %>/scripts'
+ }]
+ }
+ },
+ uglify: {
+ dist: {
+ files: {
+ '<%= yeoman.dist %>/scripts/scripts.js': [
+ '<%= yeoman.dist %>/scripts/scripts.js'
+ ],
+ }
+ }
+ },
+ copy: {
+ dist: {
+ files: [{
+ expand: true,
+ dot: true,
+ cwd: '<%= yeoman.app %>',
+ dest: '<%= yeoman.dist %>',
+ src: [
+ '*.{ico,txt}',
+ '.htaccess',
+ 'components/**/*',
+ 'images/{,*/}*.{gif,webp}'
+ ]
+ }]
+ }
}
});
- // Alias the `test` task to run `testacular` instead
- grunt.registerTask('test', 'run the testacular test driver', function () {
- var done = this.async();
- require('child_process').exec('testacular start --single-run', function (err, stdout) {
- grunt.log.write(stdout);
- done(err);
- });
- });
+ grunt.renameTask('regarde', 'watch');
+ // remove when mincss task is renamed
+ grunt.renameTask('mincss', 'cssmin');
+
+ grunt.registerTask('server', [
+ 'clean:server',
+ 'coffee:dist',
+ 'compass:server',
+ 'livereload-start',
+ 'connect:livereload',
+ 'open',
+ 'watch'
+ ]);
+
+ grunt.registerTask('test', [
+ 'clean:server',
+ 'coffee',
+ 'compass',
+ 'connect:test',
+ 'karma'
+ ]);
+
+ grunt.registerTask('build', [
+ 'clean:dist',
+ 'jshint',
+ 'test',
+ 'coffee',
+ 'compass:dist',
+ 'useminPrepare',
+ 'imagemin',
+ 'cssmin',
+ 'htmlmin',
+ 'concat',
+ 'copy',
+ 'cdnify',
+ 'usemin',
+ 'ngmin',
+ 'uglify'
+ ]);
+
+ grunt.registerTask('default', ['build']);
};
View
24 package.json
@@ -3,5 +3,27 @@
"name": "",
"version": "0.0.0",
"dependencies": {},
- "devDependencies": {}
+ "devDependencies": {
+ "grunt": "0.4.0rc7",
+ "grunt-contrib-copy": "0.4.0rc7",
+ "grunt-contrib-concat": "0.1.2rc6",
+ "grunt-contrib-coffee": "0.4.0rc7",
+ "grunt-contrib-uglify": "0.1.1rc6",
+ "grunt-contrib-compass": "~0.1.3",
+ "grunt-contrib-jshint": "0.1.1rc6",
+ "grunt-contrib-mincss": "0.4.0rc7",
+ "grunt-contrib-connect": "0.1.1rc6",
+ "grunt-contrib-clean": "0.4.0rc6",
+ "grunt-contrib-htmlmin": "0.1.1rc7",
+ "grunt-contrib-imagemin": "0.1.1rc8",
+ "grunt-contrib-livereload": "0.1.0rc8",
+ "grunt-bower-hooks": "~0.2.0",
+ "grunt-usemin": "~0.1.7",
+ "grunt-regarde": "~0.1.1",
+ "grunt-karma": "~0.3.0",
+ "grunt-open": "~0.1.0",
+ "matchdep": "~0.1.1",
+ "grunt-google-cdn": "~0.1.0",
+ "grunt-ngmin": "~0.0.1"
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.