Forgive me, I'm new to Grunt, and I usually don't code PHP. This is a new project for me. I am trying to use Grunt because it is awesome, with some html files in which minimal php. I initially installed regular grunts, not php grunt. Now I understand that maybe I should have installed grunt-php. However, I tried uninstalling gruntfile.js, installing draft-PHP, and then adding new configurations to the new gruntfile.js but the terminal continues to give me a “default” error, even if the default task certainly exists. I know that I am doing something wrong, but I do not know what. Is it easier to just add php to my original grunt file? I don’t know how I would do it. Here is the source file:
module.exports = function(grunt){
require("matchdep").filterDev("grunt-*").forEach(grunt.loadNpmTasks);
grunt.initConfig({
htmlhint: {
build: {
options: {
'tag-pair': true,
'tagname-lowercase': true,
'attr-lowercase': true,
'attr-value-double-quotes': true,
'doctype-first': true,
'spec-char-escape': true,
'id-unique': true,
'head-script-disabled': true,
'style-disabled': true
},
src: ['index.php']
}
},
watch: {
html: {
files: ['index.php'],
tasks: ['htmlhint']
},
js: {
files: ['assets/js/**/*.js'],
tasks: ['uglify']
},
css: {
files: ['assets/sass/**/*.scss'],
tasks: ['buildcss']
}
},
sass: {
build: {
files: {
'build/css/master.css': 'assets/sass/master.scss'
}
}
},
browserSync: {
files: ['*.html', 'assets/templates/*.html'],
options: {
server: {
baseDir: "./"
}
}
},
cssc: {
build: {
options: {
consolidateViaDeclarations: true,
consolidateViaSelectors: true,
consolidateMediaQueries: true
},
files: {
'build/css/master.css': 'build/css/master.css'
}
}
},
cssmin: {
build: {
src: 'build/css/master.css',
dest: 'build/css/master.css'
}
},
uglify: {
build: {
files: {
'build/js/base.min.js': ['bower_components/jquery/dis/jquery.min.js', 'bower_components/angular/angular.min.js', 'assets/js/**/*.js']
}
}
},
pkg: grunt.file.readJSON('package.json'),
phpunit:{
test:{
dir:'',
options:{
bin: 'bin/phpunit',
configuration:'app/phpunit.xml'
}
}
},
'sf2-cache-clear':{
options: {},
dev: {},
prod: {}
}
});
grunt.registerTask('buildcss', ['sass', 'cssc', 'cssmin']);
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-browser-sync');
grunt.loadNpmTasks('grunt-phpunit');
grunt.loadNpmTasks('grunt-symfony2');
grunt.registerTask('default', ['uglify', 'buildcss', 'browserSync','watch']);
grunt.registerTask('test', ['phpunit:test']);
};
grunt, grunt-php:
require('load-grunt-tasks')(grunt);
grunt.initConfig({
php: {
dist: {
options: {
hostname: '127.0.0.1',
port: 9000,
base: 'dist',
keepalive: false,
open: false
}
}
},
browserSync: {
dist: {
bsFiles: {
src: [
]
},
options: {
proxy: '<%= php.dist.options.hostname %>:<%=php.dist.options.port %>',
watchTask: true,
notify: true,
open: true,
logLevel: 'silent',
ghostMode: {
clicks: true,
scroll: true,
links: true,
forms: true
}
}
}
},
watch: {
}
});
grunt.registerTask('serve', [
'php:dist',
'browserSync:dist',
'watch'
]);
grunt.registerTask('default', ['php']);