Skip to content

Instantly share code, notes, and snippets.

@benweiser
Created June 29, 2016 05:55
Show Gist options
  • Save benweiser/1bbe13f681b597c4788dfa8d136a4162 to your computer and use it in GitHub Desktop.
Save benweiser/1bbe13f681b597c4788dfa8d136a4162 to your computer and use it in GitHub Desktop.
Gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
// Watch task config
pkg: grunt.file.readJSON('package.json'),
watch: {
sass: {
// files: "*.scss",
files: '**/*.scss',
tasks: ['sass', 'autoprefixer' ]
},
concat: {
files: 'src/**/*.js',
tasks: ['concat']
},
uglify: {
files: 'dist/global.js',
tasks: ['uglify']
}
},
// SASS task config
sass: {
dist: {
options: {
style: 'compressed'
},
files: {
// destination // source file
"style.css": "style.scss"
}
}
},
autoprefixer: {
options: {
browsers: ['last 2 version'],
map: true
},
dist: {
files: {
'style.css': 'style.css'
}
}
},
concat: {
dist: {
// the files to concatenate
src: ['src/*.js'],
// the location of the resulting JS file
dest: 'dist/global.js'
}
},
uglify: {
options: {
mangle: false
},
my_target: {
files: {
'dist/global.min.js': ['dist/global.js']
}
}
},
// inside Gruntfile.js
// Using the BrowserSync Proxy for your existing website url.
browserSync: {
default_options: {
bsFiles: {
src: [
"*.css",
"*.html",
"js/*.js",
"dist/**/*.js"
]
},
options: {
watchTask: true,
// change this to your project's location example localhost/myproject, or www.yourprojectname.dev
proxy: "<%= pkg.name %>.dev/",
tunnel: "local" // < Used for iPhone testing
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-browser-sync');
// register a default task.
grunt.registerTask('default', ['browserSync', 'watch']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment