Skip to content

Instantly share code, notes, and snippets.

@JacobLett
Last active June 21, 2023 19:06
Show Gist options
  • Save JacobLett/644d0f9f232fbd2c87b8 to your computer and use it in GitHub Desktop.
Save JacobLett/644d0f9f232fbd2c87b8 to your computer and use it in GitHub Desktop.
Bigcommerce theme development Grunt - requires local transmit webdav Mount
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
build: {
//src: ['template/js/libs/*.js', 'template/js/libs/cloudzoom/*.js', 'template/js/crafted.js'], //input
src: [
'template/js/crafted.js'], //input
dest: 'template/js/build/crafted.min.js' //output
}
},
less: {
development: {
options: {
paths: ["template/Styles/less/"],
compress: true,
cleancss: true,
},
files: {
"template/Styles/theme.css": "template/Styles/less/theme.less"
}
},
},
//http://rsync.samba.org/FAQ.html#9 Folders with spaces mess up without using ? for the space
// ,"--verbose" more information
// ,"--dry-run" use dry run to test file listing before to make sure it works correctly
// "--size-only" because most webdav implementation do not accept setting modification time
// "--no-whole-file" to tell rsync its handling a remote filesystem
// "--inplace" having rsync replacing files directly, instead of uploading an then replacing
// "--archive" : copies over new files, and updated files. Does not delete anything.
rsync: {
options: {
args: ["--verbose","--no-whole-file","--inplace","--archive"],
exclude: [".git*","*.scss","node_modules",".DS_Store","*.php"],
recursive: true
},
dist: {
options: {
src: "/local-path/",
dest: "/Volumes/transmit-mounted-site/"
}
},
},
watch: {
configFiles: {
files: [ 'Gruntfile.js', 'config/*.js' ],
options: {
reload: true
},
},
scripts: {
files: ['template/Styles/less/*.less', 'template/js/*.js'],
tasks: ['less','uglify','rsync'],
options: {
spawn: false,
livereload: true,
},
},
},
});
// END GRUNT
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-webdav-sync');
grunt.loadNpmTasks('grunt-rsync');
grunt.loadNpmTasks('grunt-contrib-watch');
// grunt.loadNpmTasks('grunt-contrib-cssmin');
// Default task(s).
grunt.registerTask('default', ['uglify','less', 'rsync','watch']);
};
@clnmcgrw
Copy link

Jacob, thanks a ton for this. I was having trouble with webdav-sync also, this works perfectly.

@zackmedia
Copy link

Did you manage to get it to only rsync the modified/changed files? This is uploading my entire directory each time I change a file, which takes forever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment