Leo Torres
asked on
Grunt No Clean Targets
I dont under stand what is happening here with running my Gruntfile.js I am run at from a MACOS and Windows server 2012 both gave me exact error
This is my Gruntfile.js
Below is my output
Here is a list of the directory
This is my Gruntfile.js
'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']);
};
Below is my output
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>
Here is a list of the directory
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I got the answer. Will keep yours as an alternative approach.
I copied your file and looked for grunt.load which I did not find. The registerTask calls at the end just declare the tasks which can consist of other internal tasks as an external task. The Grunt functionality is held in the grunt.loadNpmTask() calls. These, as far as I can remember can be external, but if you git everything and distrubte it elsewhere it is a good idea to encapsulate everything internally (I git my entire project grunt file, package.json and so on, which makes it easy to reinstall.
There is a good little book which I highly recommend "Automate with Grunt" by Brian Hogan
https://www.amazon.com/Automate-Grunt-Build-Tool-JavaScript/dp/1941222110/ref=sr_1_1?ie=UTF8&qid=1477227096&sr=8-1&keywords=automate+with+grunt
which for around 10 bucks is not bad.
There is a good little book which I highly recommend "Automate with Grunt" by Brian Hogan
https://www.amazon.com/Automate-Grunt-Build-Tool-JavaScript/dp/1941222110/ref=sr_1_1?ie=UTF8&qid=1477227096&sr=8-1&keywords=automate+with+grunt
which for around 10 bucks is not bad.
ASKER
Great I will look into the book.
On another note. I can start a new thread but I cant understand why grunt works on my MACOS but not windows server 2012.
Folder sits on a share runs fine on Mac Windows gives error below. And yes Powershell and Command line were opened as ADMIN.
Would you like a new thread?
On another note. I can start a new thread but I cant understand why grunt works on my MACOS but not windows server 2012.
Folder sits on a share runs fine on Mac Windows gives error below. And yes Powershell and Command line were opened as ADMIN.
Writing dist\styles\main.css...Warning: Unable to create directory "V:\ProgramData\AngularJS\Week2vs\conFusion\dist" (Error code: EEXIST). Use --force
to continue.
Would you like a new thread?
Well this time no. My clean clears out build and dist :
and as far as I remember it deletes both. Which means that they'll be recreated on build. Why do you have a funny directory structure build/src/dist?
I must admit to having set up my directory structure with Yeoman. It also generated all the relevant files as well.
clean: ['build', 'dist'
],
and as far as I remember it deletes both. Which means that they'll be recreated on build. Why do you have a funny directory structure build/src/dist?
I must admit to having set up my directory structure with Yeoman. It also generated all the relevant files as well.
ASKER
I finally got it to work. The open and closed braces were incorrectly placed.
Open in new window