Skip to content

Instantly share code, notes, and snippets.

@chrillewoodz
Last active August 26, 2015 12:42
Show Gist options
  • Save chrillewoodz/f4f05345f3ad46300091 to your computer and use it in GitHub Desktop.
Save chrillewoodz/f4f05345f3ad46300091 to your computer and use it in GitHub Desktop.
module.exports = function(grunt) {
// Load all tasks
require('load-grunt-tasks')(grunt);
require('time-grunt')(grunt);
var mozjpeg = require('imagemin-mozjpeg');
var htmlFileList = [
'index.html'
];
var cssFileList = [
];
var jsFileList = [
'assets/scripts/vendors/jcolumn.min.js'
];
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
separator: ';'
},
dev: {
files: {
'static/main.min.js': ['assets/scripts/**/*.jsx'],
'static/vendors.min.js': [jsFileList]
}
},
build: {
files: {
'dist/static/main.min.js': ['assets/scripts/**/*.jsx'],
'dist/static/vendors.min.js': [jsFileList]
}
}
},
babel: {
options: {
sourceMap: true
},
dev: {
files: {
'static/main.min.js': 'static/main.min.js'
}
},
build: {
files: {
'dist/static/main.min.js': 'dist/static/main.min.js'
}
}
},
uglify: {
build: {
files: {
'dist/static/main.min.js': 'dist/static/main.min.js',
'dist/static/vendors.min.js': [jsFileList]
}
}
},
imagemin: {
dynamic: {
options: {
optimizationLevel: 4,
svgoPlugins: [{ removeViewBox: false }],
progressive: true,
use: [mozjpeg({quality: 80})]
},
files: [{
expand: true, // Enable dynamic expansion
cwd: 'assets/images/', // Src matches are relative to this path
src: ['**/*.{png,jpg,gif,svg}'], // Actual patterns to match
dest: 'dist/assets/images' // Destination path prefix
}]
}
},
sass: {
dev: {
options: {
style: 'expanded',
sourcemap: 'auto'
},
files: {
'assets/styles/style.css': 'assets/styles/style.scss'
}
},
build: {
options: {
style: 'compressed'
},
files: {
'dist/assets/styles/style.min.css': 'assets/styles/style.scss'
}
}
},
autoprefixer: {
options: {
browsers: ['last 2 versions', '> 1%', 'ff > 20', 'ie 8', 'ie 9', 'android 2.3', 'android 4', 'opera 12']
},
dev: {
options: {
map: {
prev: 'assets/styles/'
}
},
src: 'assets/styles/style.css'
},
build: {
src: 'assets/styles/style.css'
}
},
processhtml: {
build: {
files: {
'dist/index.html': ['index.html']
}
}
},
uncss: {
options: {
compress: true,
report: 'min',
},
build: {
files: {
'dist/assets/styles/style.min.css': [htmlFileList]
}
}
},
copy:{
build: {
files: [
{
expand: true,
cwd: 'assets/fonts/',
src: ['**'],
dest: 'dist/assets/fonts/',
flatten: true,
filter: 'isFile'
},
{
expand: true,
cwd: '',
src: 'favicon.ico',
dest: 'dist/',
flatten: true,
filter: 'isFile'
}
]
}
},
'ftp-deploy': {
deploy: {
auth: {
authPath: '../.ftppass',
host: 'HOSTHERE',
port: 21,
authKey: 'key1',
},
src: 'dist/',
dest: 'ftpdeploytest/',
exclusions: [
'.DS_Store',
'.gitignore',
'.ftppass'
]
}
},
connect: {
all: {
options:{
port: 9000,
hostname: "0.0.0.0",
keepalive: false
}
}
},
open: {
all: {
path: 'http://localhost:<%= connect.all.options.port%>'
}
},
browserSync: {
dev: {
bsFiles: {
src : [
'assets/styles/style.css',
'*.html'
]
},
options: {
watchTask: true,
server: '.'
}
}
},
watch: {
js: {
files: ['assets/scripts/**/*.js', 'assets/scripts/**/*.jsx'],
tasks: ['concat:dev', 'babel:dev'],
options: {
spawn: false
}
},
css: {
files: ['assets/styles/**/*.scss'],
tasks: ['sass:dev', 'autoprefixer:dev']
}
}
});
grunt.registerTask('default', [
'dev'
]);
grunt.registerTask('dev', [
'sass:dev',
'autoprefixer:dev',
'concat'
]);
grunt.registerTask('build', [
'newer:sass:build',
'newer:autoprefixer:build',
'newer:concat:build',
'newer:babel:build',
'newer:uglify',
'newer:imagemin',
'processhtml',
'newer:uncss',
'newer:copy:build'
]);
grunt.registerTask('live', [
'dev',
'browserSync',
'watch'
]);
grunt.registerTask('serve',[
'dev',
'open',
'connect',
'watch'
]);
grunt.registerTask('deploy', [
'build',
'ftp-deploy'
]);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment