Created
March 27, 2019 03:29
-
-
Save devinsays/768c1d8faf487ddf54425cf2bbbc6d4a to your computer and use it in GitHub Desktop.
Updated Gruntfile.js with Working Autoprefixer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
// Packages | |
const fiberLibrary = require('fibers'); | |
const sassLibrary = require('node-sass'); | |
module.exports = function(grunt) { | |
// load all tasks | |
require('load-grunt-tasks')(grunt, {scope: 'devDependencies'}); | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
watch: { | |
files: ['assets/scss/**/*.scss', 'assets/js/**/*.js'], | |
tasks: ['sass', 'postcss', 'cssmin', 'concat', 'uglify'], | |
options: { | |
livereload: true, | |
}, | |
}, | |
sass: { | |
default: { | |
options : { | |
implementation: sassLibrary, | |
fiber: fiberLibrary, | |
style : 'expanded', | |
sourceMap: true | |
}, | |
files: { | |
'css/style.css':'assets/scss/style.scss', | |
'css/jobvite.css':'assets/scss/jobvite.scss' | |
} | |
} | |
}, | |
postcss: { | |
options: { | |
map: true, | |
processors: [ | |
require('autoprefixer')({browsers: 'last 2 versions, > 2%'}), | |
] | |
}, | |
dist: { | |
files: [{ | |
src: ['css/*.css', 'css/!*.min.css'], | |
}] | |
} | |
}, | |
cssmin: { | |
options: { | |
aggressiveMerging : false, | |
sourceMap: true | |
}, | |
target: { | |
files: [{ | |
expand: true, | |
cwd: 'css', | |
src: ['*.css', '!*.min.css'], | |
dest: 'css', | |
ext: '.min.css' | |
}] | |
} | |
}, | |
babel: { | |
options: { | |
sourceMap: true, | |
presets: [ | |
['@babel/preset-env', | |
{ | |
"targets": { | |
"ie": "11" | |
} | |
}] | |
] | |
}, | |
dist: { | |
files: { | |
'js/compiled/progress-line.js': 'assets/js/progress-line.js', | |
'js/compiled/pts.js': 'assets/js/pts.js', | |
'js/compiled/easings.js': 'assets/js/vendor/easings.js', | |
'js/compiled/navigation.js': 'assets/js/navigation.js', | |
'js/compiled/theme.js': 'assets/js/theme.js', | |
} | |
} | |
}, | |
concat: { | |
default: { | |
files: { | |
'js/compiled/nano.combined.js' : [ | |
'assets/js/vendor/skip-link-focus-fix.js', | |
'assets/js/vendor/jquery.fitvids.js', | |
'js/compiled/easings.js', | |
'js/compiled/navigation.js', | |
'js/compiled/theme.js' | |
], | |
'js/compiled/pts.combined.js' : [ | |
'assets/js/vendor/pts.min.js', | |
'js/compiled/pts.js', | |
], | |
'js/compiled/flickity.combined.js' : [ | |
'assets/js/vendor/flickity.pkgd.min.js', | |
'assets/js/flickity.js', | |
] | |
} | |
} | |
}, | |
uglify: { | |
options: { | |
mangle: { | |
reserved: ['jQuery'] | |
}, | |
drop_console: false, | |
drop_debugger: false | |
}, | |
default: { | |
files: { | |
'js/progress-line.min.js': 'js/compiled/progress-line.js', | |
'js/flickity.min.js': 'js/compiled/flickity.combined.js', | |
'js/nano.min.js': 'js/compiled/nano.combined.js', | |
'js/pts.min.js': 'js/compiled/pts.combined.js' | |
} | |
} | |
}, | |
replace: { | |
styleVersion: { | |
src: [ | |
'assets/scss/style.scss', | |
'style.css' | |
], | |
overwrite: true, | |
replacements: [{ | |
from: /Version:.*$/m, | |
to: 'Version: <%= pkg.version %>' | |
}] | |
}, | |
functionsVersion: { | |
src: [ | |
'functions.php' | |
], | |
overwrite: true, | |
replacements: [ { | |
from: /^define\( 'NANO_VERSION'.*$/m, | |
to: 'define( \'NANO_VERSION\', \'<%= pkg.version %>\' );' | |
} ] | |
}, | |
}, | |
// https://www.npmjs.org/package/grunt-wp-i18n | |
makepot: { | |
target: { | |
options: { | |
domainPath: '/languages/', | |
potFilename: 'nanovision.pot', | |
potHeaders: { | |
poedit: true, // Includes common Poedit headers. | |
'x-poedit-keywordslist': true // Include a list of all possible gettext functions. | |
}, | |
type: 'wp-theme', | |
updateTimestamp: false, | |
processPot: function( pot, options ) { | |
pot.headers['language'] = 'en_US'; | |
return pot; | |
} | |
} | |
} | |
} | |
}); | |
grunt.registerTask( 'default', [ | |
'sass', | |
'postcss', | |
'cssmin', | |
'babel', | |
'concat', | |
'uglify' | |
]); | |
grunt.registerTask( 'release', [ | |
'replace', | |
'sass', | |
'postcss', | |
'cssmin', | |
'babel', | |
'concat', | |
'uglify', | |
'makepot' | |
]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment