Setup Grunt

Install Grunt globally.

npm install -g grunt-cli

Create a black Gruntfile.js

Create package.json with CMD.

npm init

package.json

{
“name”: “laraevents”,
“version”: “1.0.0”,
“description”: “events site”,
“main”: “Gruntfile.js”,
“scripts”: {
“test”: “echo \”Error: no test specified\” && exit 1″
},
“author”: “”,
“license”: “ISC”,
}

Now install grunt to your local project.

npm install grunt --save-dev

Install Grunt Plugins.

https://www.npmjs.com/package/grunt-contrib-watch

npm i grunt-contrib-watch

https://www.npmjs.com/package/grunt-contrib-sass

npm i grunt-contrib-sass

https://www.npmjs.com/package/grunt-contrib-pug

npm i grunt-contrib-pug

Gruntfile.js

module.exports = function(grunt){
// Project config
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
sass: {
files: ['dev/scss/*.sass', 'dev/*.pug'],
tasks: ['sass', 'pug']
}
},
sass: {
dist: {
files: {
'html/css/style.css' : 'dev/scss/style.sass'
}
}
},
pug: {
compile: {
options: {
data: {
debug: true
}
},
files: {
'html/index.html' : ['dev/index.pug']
}
}
}
})

grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-pug');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['sass', 'pug']);
}

Leave a Reply

Your email address will not be published. Required fields are marked *