-
-
Save rodebert/e322f0993521005c7a9a7343a1592879 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
require('time-grunt')(grunt); | |
require('load-grunt-tasks')(grunt); | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
copy: { | |
dist: { | |
files: [{ | |
expand: true, | |
cwd: 'site/dev', | |
src: ['**', '!sass/**'], | |
dest: 'site/dist/' | |
}] | |
}, // dist | |
html: { | |
files: [{ | |
expand: true, | |
cwd: 'site/dev', | |
src: ['css/**', 'js/**', 'images/**'], | |
dest: 'site/html/' | |
}] | |
}, // html | |
styleguide: { | |
files: [{ | |
expand: true, | |
cwd: 'site/dev', | |
src: ['css/**', 'js/**', 'images/**'], | |
dest: 'site/styleguide/' | |
}] | |
}, | |
htmlstyleguide: { | |
files: [{ | |
expand: true, | |
cwd: 'site/styleguide', | |
src: ['css/**', 'js/**', 'images/**'], | |
dest: 'site/html-styleguide/' | |
}] | |
} | |
}, //copy | |
// remove all files from folder xxx | |
clean: { | |
dist: ['site/dist'], | |
html: ['site/html'], | |
htmlstyleguide: ['site/html-styleguide'] | |
}, | |
sass: { | |
dev: { | |
options: { | |
sourceMap: false, | |
outputStyle: 'expanded' | |
} , | |
files: [{ | |
expand: true, | |
cwd: 'site/dev/sass', | |
src: ['*.scss'], | |
dest: 'site/dev/css', | |
ext: '.css' | |
}] | |
}, | |
styleguide: { | |
options: { | |
sourceMap: false, | |
outputStyle: 'expanded' | |
}, | |
files: [{ | |
expand: true, | |
cwd: 'site/styleguide/sass', | |
src: ['*.scss'], | |
dest: 'site/styleguide/css', | |
ext: '.css' | |
}] | |
} | |
}, // sass | |
watch: { | |
dev: { | |
files: ['site/dev/sass/**/*.scss'], | |
tasks: ['sass:dev'] | |
}, | |
styleguide: { | |
files: ['site/styleguide/sass/**/*.scss'], | |
tasks: ['sass:styleguide', 'postcss:styleguide'] | |
} | |
}, // watch | |
php2html: { | |
dev: { | |
options: { | |
// Task-specific options go here. | |
// relative links should be renamed from .php to .html | |
processLinks: true, | |
htmlhint: { | |
'tagname-lowercase': true, | |
'attr-lowercase': true, | |
'attr-value-double-quotes': true, | |
'doctype-first': true, | |
'tag-pair': true, | |
'spec-char-escape': true, | |
'id-unique': true, | |
'src-not-empty': true | |
}, // htmlhint | |
docroot: 'site/dev' | |
}, // options | |
files: [{ | |
expand: true, | |
cwd: 'site/dev/', | |
src: ['*.php'], | |
dest: 'site/html', | |
ext: '.html' | |
}] | |
}, // default | |
styleguide: { | |
options: { | |
// Task-specific options go here. | |
// relative links should be renamed from .php to .html | |
processLinks: true, | |
htmlhint: { | |
'tagname-lowercase': true, | |
'attr-lowercase': true, | |
'attr-value-double-quotes': true, | |
'doctype-first': true, | |
'tag-pair': true, | |
'spec-char-escape': true, | |
'id-unique': true, | |
'src-not-empty': true | |
}, // htmlhint | |
docroot: 'site/styleguide' | |
}, // options | |
files: [{ | |
expand: true, | |
cwd: 'site/styleguide/', | |
src: ['*.php'], | |
dest: 'site/html-styleguide', | |
ext: '.html' | |
}] | |
}// styleguide | |
}, // php2html | |
validation: { | |
options: { | |
reset: grunt.option('reset') || false, | |
stoponerror: false | |
}, | |
files: { | |
src: ['site/html/*.html'] | |
} | |
}, // validation | |
analyzecss: { | |
prod: { | |
sources: ['site/html/css.css'] | |
}, | |
options: { | |
outputMetrics: 'error', | |
softFail: false, | |
thresholds: { | |
selectors: 4096, | |
// diese Checks werden nicht durchlaufen | |
redundantBodySelectors: null, | |
comments: null, | |
commentsLength: null, | |
complexSelectors: null, | |
complexSelectorsByAttribute: null, | |
duplicatedSelectors: null, | |
emptyRules: null, | |
expressions: null, | |
oldIEFixes: null, | |
importants: null, | |
mediaQueries: null, | |
oldPropertyPrefixes: null, | |
qualifiedSelectors: null, | |
specificityIdAvg: null, | |
specificityIdTotal: null, | |
specificityClassAvg: null, | |
specificityClassTotal: null, | |
specificityTagAvg: null, | |
specificityTagTotal: null, | |
selectorsByAttribute: null, | |
selectorsByClass: null, | |
selectorsById: null, | |
selectorsByPseudo: null, | |
selectorsByTag: null, | |
universalSelectors: null, | |
length: null, | |
rules: null, | |
declarations: null | |
} | |
} | |
}, // analyzecss | |
postcss: { | |
options: { | |
map: { | |
inline: false, // saving sourcemaps as separate files | |
annotation: 'site/dev/css/' // putting sourcemaps here | |
}, | |
processors: [ | |
require('autoprefixer')({ | |
browsers: ['last 2 versions', '> 1%', 'iOS >= 6', 'Android > 3', 'ie > 8', 'Firefox ESR'] | |
}) | |
] | |
}, | |
main: { | |
src: 'site/dev/css/styles.css', | |
dest: 'site/dev/css/css.css' | |
}, | |
styleguide: { | |
src: 'site/styleguide/css/styleguide.css', | |
dest: 'site/styleguide/css/styleguide-neu.css' | |
} | |
} // postCSS | |
}); // grunt.initConfig | |
grunt.registerTask('default', ['watch:dev']); | |
grunt.registerTask('sg-watch', ['watch:styleguide']); | |
grunt.registerTask('dist', ['clean:dist', 'copy:dist', 'replace:dist']); | |
grunt.registerTask('html', ['clean:html', 'php2html:dev', 'copy:html', 'validation' ]); | |
grunt.registerTask('html-sg', ['clean:htmlstyleguide', 'sass:styleguide', 'php2html:styleguide','copy:htmlstyleguide']); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Diese Zeile gehört noch oben rein, bringt aber leider auch keine Veränderung:
// This one line spares us the call for each task at the end of the gruntfile. require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);