Skip to content

Commit

Permalink
Add support to Stylus preprocessor CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
edpittol committed Jun 17, 2016
1 parent a2b788c commit b413106
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 7 deletions.
37 changes: 37 additions & 0 deletions .stylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"blocks": false,
"brackets": false,
"colons": false,
"colors": {
"expect": "always"
},
"commaSpace": "always",
"commentSpace": "always",
"cssLiteral": "never",
"depthLimit": 4,
"duplicates": true,
"efficient": "always",
"extendPref": false,
"globalDupe": false,
"indentPref": 2,
"leadingZero": "never",
"maxErrors": false,
"maxWarnings": false,
"mixed": true,
"namingConvention": "BEM",
"namingConventionStrict": true,
"none": "always",
"noImportant": true,
"parenSpace": "always",
"placeholders": "always",
"prefixVarsWithDollar": "always",
"quotePref": "single",
"semicolons": false,
"sortOrder": "alphabetical",
"stackedProperties": "never",
"trailingWhitespace": "never",
"universal": false,
"valid": true,
"zeroUnits": "never",
"zIndexNormalize": false
}
45 changes: 39 additions & 6 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ module.exports = function( grunt ) {

grunt.initConfig({
pkg: grunt.file.readJSON( 'package.json' ),
config: {
server: 'public/wp-content/themes/<%= pkg.name %>',
},

// watch for changes for files and execute an execute a task
watch: {
Expand All @@ -18,26 +21,56 @@ module.exports = function( grunt ) {
}
},
theme: {
files: 'theme/**/*',
files: 'theme/src/**/*',
tasks: ['sync:theme']
},
stylus: {
files: ['.stylintrc', 'theme/stylus/**/*.styl'],
tasks: ['stylint', 'stylus:dev']
},
},

// sync the files with local test wordpress
sync : {
theme : {
files : [ {
cwd : 'theme',
cwd : 'theme/src',
src : '**',
dest : 'public/wp-content/themes/<%= pkg.name %>'
dest : '<%= config.server %>'
} ],
pretend : false,
verbose: true,
updateAndDelete: true
}
}
},

// compile stylus file
stylus: {
dev: {
options: {
compress: false,
linenos: true
},
files : {
'<%= config.server %>/assets/css/style.css' : 'theme/stylus/style.styl'
}
},
dist: {
files : {
'<%= config.server %>/assets/css/style.css' : 'theme/stylus/style.styl'
}
}
},

// lint stylus files
stylint: {
src: ['theme/stylus/**/*.styl']
},
});

// default task: build and sync files with the blog test
grunt.task.registerTask( 'default', [ 'sync:theme' ] );
// default task: build the theme to development
grunt.task.registerTask('default', ['sync:theme', 'stylint', 'stylus:dev']);

// dist task: build the theme to production
grunt.task.registerTask('dist', ['sync:theme', 'stylint', 'stylus:dist']);
};
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ The default task update the project with the server. Execute this task before st
Listen all changes in the project files. This command is integrated with the [Livereload](http://livereload.com/extensions/) browser extension. To any server file change, the browser automatically refresh the page. This command maintain alive until you kill it with a `ctrl + c`. Maintain alive while you work in the development.

$ grunt watch

## Stylus

This env use stylus to preprocess the CSS styles. The files stay inner the `theme/stylus`. The files is processed by grunt tasks. Read the [Stylus documentation](http://stylus-lang.com/).

## Starting development

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
"license": "GPL-2.0",
"main": "Gruntfile.js",
"devDependencies": {
"grunt": "^1.0.1",
"grunt": "^0.4.5",
"grunt-contrib-stylus": "^1.2.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-stylint": "^0.1.2",
"grunt-sync": "^0.5.2",
"load-grunt-tasks": "^3.5.0"
}
Expand Down
3 changes: 3 additions & 0 deletions theme/src/functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

require_once 'includes/myenvpress.php';
9 changes: 9 additions & 0 deletions theme/src/includes/myenvpress.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

/**
* Enque the theme style.
*/
function myenvpress_enqueue_scripts() {
wp_enqueue_script( 'myenvpress', get_stylesheet_directory_uri() . '/assets/css/style.css' );
}
add_action( 'wp_enqueue_scripts', 'myenvpress_enqueue_scripts' );
File renamed without changes
File renamed without changes.
Empty file added theme/stylus/style.styl
Empty file.

0 comments on commit b413106

Please sign in to comment.