Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a basic Grunt setup as well as added a function in the function… #1

Merged
merged 1 commit into from
Sep 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
124 changes: 124 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
module.exports = function(grunt) {

grunt.initConfig({
concat: {
js: {
options: {
separator: ';'
},
src: [
'library/js/*.js',
'!library/js/scripts-min.js'
],
dest: 'library/js/scripts-min.js'
},
},

svgstore: {
options: {
prefix: 'icon-',
svg: {
class: 'hide'
}
},
default : {
files: {
'library/images/svg/processed/svg-defs.svg': ['library/images/svg/*.svg'],
},
}
},

uglify: {
options: {
mangle: false
},
js: {
files: {
'library/js/scripts-min.js': ['library/js/scripts-min.js']
}
}
},

less: {
style: {
files: {
"library/css/style.css": "library/less/style.less"
},
}
},

sass: { // Task
dist: { // Target
options: { // Target options
style: 'expanded'
},
files: { // Dictionary of files
'library/css/style.css': 'library/scss/style.scss', // 'destination': 'source'
'library/css/editor-style.css': 'library/scss/editor-style.scss',
'library/css/login.css': 'library/scss/login.scss'
}
}
},

autoprefixer:{
dist:{
files:{
'library/css/style.css':'library/css/style.css'
}
}
},
cssmin: {
target: {
files: [{
expand: true,
cwd: 'library/css',
src: ['*.css', '!*.min.css'],
dest: 'library/css',
ext: '.min.css'
}]
}
},
watch: {
js: {
files: ['library/js/*.js', '!libary/js/scripts-min.js'],
tasks: ['concat:js', 'uglify:js'],
options: {
livereload: true
}
},
css: {
files: ['library/scss/**/*.scss'],
tasks: ['sass', 'autoprefixer', 'cssmin'],
options: {

}
},
php : {
files: ['**/*.php'],
options: {
livereload: true
}
},
svg : {
files: ['library/images/svg/*.svg'],
tasks: ['svgstore:default']
},
livereload: {
files: ['library/css/style.css', 'library/images/svg/processed/svg-defs.svg'],
options: { livereload: true }
}
}
});

grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-svgstore');
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.loadNpmTasks('grunt-contrib-cssmin');

grunt.registerTask('default', ['watch']);
grunt.registerTask('svg', ['svgstore']);
};

38 changes: 33 additions & 5 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -771,12 +771,28 @@ function template_custom_quicktags() {
// Load dashicons on the front end
// To use, go here and copy the css/html for the dashicon you want: https://developer.wordpress.org/resource/dashicons/
// Example: <span class="dashicons dashicons-wordpress"></span>
add_action( 'wp_enqueue_scripts', 'template_load_dashicons' );
function template_load_dashicons() {
wp_enqueue_style( 'dashicons' );
}

// add_action( 'wp_enqueue_scripts', 'template_load_dashicons' );
// function template_load_dashicons() {
// wp_enqueue_style( 'dashicons' );
// }

// Remove wp-embed.min.js from the front end
add_action( 'init', function() {

// Remove the REST API endpoint.
remove_action('rest_api_init', 'wp_oembed_register_route');

// Turn off oEmbed auto discovery.
// Don't filter oEmbed results.
remove_filter('oembed_dataparse', 'wp_filter_oembed_result', 10);

// Remove oEmbed discovery links.
remove_action('wp_head', 'wp_oembed_add_discovery_links');

// Remove oEmbed-specific JavaScript from the front-end and back-end.
remove_action('wp_head', 'wp_oembed_add_host_js');
}, PHP_INT_MAX - 1 );

// Post Author function (from WP Twenty Seventeen theme)
// We use this in the byline template part but included here in case you want to use it elsewhere.
if ( ! function_exists( 'template_posted_on' ) ) :
Expand Down Expand Up @@ -824,4 +840,16 @@ function template_time_link() {
}
endif;


// Live Reload for Grunt during development
//If your site is running locally it will load the livereload js file into the footer. This makes it possible for the browser to reload after a change has been made.
if (in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'))) {
function livereload_script() {
wp_register_script('livereload', 'http://localhost:35729/livereload.js?snipver=1', null, false, true);
wp_enqueue_script('livereload');
}

add_action( 'wp_enqueue_scripts', 'livereload_script' );
}

?>
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "BoilerPlate",
"version": "0.0.2",
"devDependencies": {
"connect-livereload": "*",
"grunt": "*",
"grunt-autoprefixer": "*",
"grunt-contrib-concat": "*",
"grunt-contrib-cssmin": "*",
"grunt-contrib-sass": "*",
"grunt-contrib-uglify": "*",
"grunt-contrib-watch": "*",
"grunt-svgstore": "*"
}
}