Sample grunt configuration (for sassified underscores.me theme)
module.exports = function(grunt) { | |
const sass = require('node-sass'); | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
sass: { | |
options: { | |
sourceMap: false, | |
implementation: sass | |
}, | |
dist: { | |
files: { | |
'wp-content/themes/example-theme/style.css': 'wp-content/themes/example-theme/sass/style.scss' | |
} | |
} | |
}, | |
postcss: { | |
options: { | |
processors: [ | |
require('autoprefixer')({ | |
browsers: ['last 2 versions'] | |
}) | |
] | |
}, | |
dist: { | |
src: 'wp-content/themes/example-theme/style.css', | |
dest: 'wp-content/themes/example-theme/style.css' | |
} | |
}, | |
watch: { | |
grunt: { | |
options: { | |
reload: true | |
}, | |
files: ['Gruntfile.js'] | |
}, | |
sass: { | |
files: ['wp-content/themes/example-theme/**/*.scss'], | |
tasks: ['sass', 'postcss'] | |
} | |
}, | |
browserSync: { | |
dev: { | |
bsFiles: { | |
src: [ | |
'wp-content/themes/example-theme/style.css', | |
'wp-content/themes/example-theme/**/*.php' | |
] | |
}, | |
options: { | |
watchTask: true, | |
proxy: 'localhost/example-wp' | |
} | |
} | |
} | |
}); | |
//register tasks | |
grunt.loadNpmTasks('grunt-sass'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadNpmTasks('grunt-browser-sync'); | |
grunt.loadNpmTasks('grunt-postcss'); | |
grunt.registerTask('default', ['sass', 'postcss', 'browserSync', 'watch']); | |
}; |
{ | |
"name": "example.com", | |
"version": "1.0.0", | |
"description": "Example grunt package", | |
"repository": { | |
"type": "git", | |
"url": "git+https://example.com/example.git" | |
}, | |
"scripts": { | |
"build": "grunt" | |
}, | |
"author": "Me and myself", | |
"license": "UNLICENSED", | |
"homepage": "https://example.com", | |
"devDependencies": { | |
"autoprefixer": "^8.2.0", | |
"grunt": "^1.0.3", | |
"grunt-browser-sync": "^2.2.0", | |
"grunt-cli": "^1.3.2", | |
"grunt-contrib-watch": "^1.1.0", | |
"grunt-postcss": "^0.9.0", | |
"grunt-sass": "^3.0.2", | |
"node-sass": "^4.10.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment