asked on
'use strict';
module.exports = function (grunt) {
// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);
// Automatically load required Grunt tasks
require('jit-grunt')(grunt, {
useminPrepare: 'grunt-usemin'
});
// Define the configuration for all the tasks
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Make sure code styles are up to par and there are no obvious mistakes
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
all: {
src: [
'Gruntfile.js',
'app/scripts/{,*/}*.js'
]
}
},
useminPrepare: {
html: 'app/menu.html',
useminPrepare: {
html: 'app/menu.html',
options: {
dest: 'dist'
}
},
// Concat
concat: {
options: {
separator: ';'
},
// dist configuration is provided by useminPrepare
dist: {}
},
// Uglify
uglify: {
// dist configuration is provided by useminPrepare
dist: {}
},
cssmin: {
dist: {}
},
// Filerev
filerev: {
options: {
encoding: 'utf8',
algorithm: 'md5',
length: 20
},
release: {
// filerev:release hashes(md5) all assets (images, js and css )
// in dist directory
files: [{
src: [
'dist/scripts/*.js',
'dist/styles/*.css',
]
}]
}
},
// Usemin
// Replaces all assets with their revved version in html and css files.
// options.assetDirs contains the directories for finding the assets
// according to their relative paths
usemin: {
html: ['dist/*.html'],
css: ['dist/styles/*.css'],
options: {
assetsDirs: ['dist', 'dist/styles']
}
},
copy: {
dist: {
cwd: 'app',
src: ['**', '!styles/**/*.css', '!scripts/**/*.js'],
dest: 'dist',
expand: true
},
fonts: {
files: [
{
//for bootstrap fonts
expand: true,
dot: true,
cwd: 'bower_components/bootstrap/dist',
src: ['fonts/*.*'],
dest: 'dist'
}, {
//for font-awesome
expand: true,
dot: true,
cwd: 'bower_components/font-awesome',
src: ['fonts/*.*'],
dest: 'dist'
}
]
}
},
clean: {
build: {
src: ['dist/']
}
}
}
});
grunt.registerTask('build', [
'clean',
'jshint',
'useminPrepare',
'concat',
'cssmin',
'uglify',
'copy',
'filerev',
'usemin'
]);
grunt.registerTask('default',['build']);
};
PS V:\ProgramData\Coursera\AngularJS\Week2vs\conFusion> grunt -v
Initializing
Command-line options: --verbose
Reading "Gruntfile.js" Gruntfile...OK
Registering Gruntfile tasks.
Reading package.json...OK
Parsing package.json...OK
Initializing config...OK
Loading "Gruntfile.js" tasks...OK
+ build, default
No tasks specified, running default tasks.
Running tasks: default
Running "default" task
Running "build" task
Loading "grunt-contrib-clean" plugin
Registering "V:\ProgramData\Coursera\AngularJS\Week2vs\conFusion\node_modules\grunt-contrib-clean\tasks" tasks.
Loading "clean.js" tasks...OK
+ clean
Running "clean" task
>> No "clean" targets found.
Warning: Task "clean" failed. Use --force to continue.
Aborted due to warnings.
Execution Time (2016-10-21 23:44:36 UTC-4)
loading tasks 971ms ███████████████████████████████████████████████████████ 75%
loading grunt-contrib-clean 332ms ███████████████████ 25%
Total 1.3s
PS V:\ProgramData\Coursera\AngularJS\Week2vs\conFusion>
PS V:\ProgramData\Coursera\AngularJS\Week2vs\conFusion> ls
Directory: V:\ProgramData\Coursera\AngularJS\Week2vs\conFusion
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 10/21/2016 11:43 PM node_modules
d---- 10/16/2016 11:11 PM img
d---- 10/18/2016 1:22 AM app
d---- 10/16/2016 11:11 PM css
d---- 10/16/2016 11:11 PM bower_components
d---- 10/16/2016 11:11 PM js
d---- 10/21/2016 12:44 AM dist
d---- 10/16/2016 11:11 PM __MACOSX
d---- 10/16/2016 11:11 PM fonts
-a--- 10/21/2016 11:48 PM 3223 Gruntfile.js
-a--- 7/14/2016 11:05 PM 14624 aboutus.html
-a--- 7/19/2016 11:14 PM 426 bower.json
-a--- 7/4/2016 9:30 AM 12505 contactus.html
-a--- 7/21/2016 7:54 AM 22837 index.html
-a--- 10/21/2016 11:43 PM 588 package.json
-a--- 10/20/2016 11:05 PM 3933 Gruntfile_new2.js
-a--- 10/19/2016 11:12 PM 2904 Gruntfile_new.js
PS V:\ProgramData\Coursera\AngularJS\Week2vs\conFusion>
As you can see the dist folder is present line #15. I have been at this for a week now.