Giter Club home page Giter Club logo

grunt-contrib-stylus's Introduction

grunt-contrib-stylus v1.2.0 Build Status: Linux Build Status: Windows

Compile Stylus files to CSS

Getting Started

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-contrib-stylus --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-contrib-stylus');

This plugin was designed to work with Grunt 0.4.x. If you're still using grunt v0.3.x it's strongly recommended that you upgrade, but in case you can't please use v0.3.1.

Stylus task

Run this task with the grunt stylus command.

Task targets, files and options may be specified according to the grunt Configuring tasks guide.

This task comes preloaded with nib.

Options

compress

Type: Boolean
Default: true

Specifies if we should compress the compiled css. Compression is always disabled when --debug flag is passed to grunt.

linenos

Type: Boolean
Default: false

Specifies if the generated CSS file should contain comments indicating the corresponding stylus line.

firebug

Type: Boolean
Default: false

Specifies if the generated CSS file should contain debug info that can be used by the FireStylus Firebug plugin.

paths

Type: Array

Specifies directories to scan for @import directives when parsing.

define

Type: Object

Allows you to define global variables in Gruntfile that will be accessible in Stylus files.

rawDefine

Type: Boolean|Array|String

If set to true, defines global variables in Gruntfile without casting objects to Stylus lists. Allows using a JavaScript object in Gruntfile to be accessible as a Stylus Hash. See Stylus's issue tracker for details. stylus/stylus#1286

Allows passing an array or string to specify individual keys to define "raw", casting all other keys as default Stylus behavior.

urlfunc

Type: String|Object

If String: specifies function name that should be used for embedding images as Data URI.

If Object:

  • name - Type: String. Function name that should be used for embedding images as Data URI.
  • [ limit ] - Type: Number|Boolean Default: 30000. Bytesize limit defaulting to 30Kb (30000), use false to disable the limit.
  • [ [paths ] - Type: Array, Default: []. Image resolution path(s).

See url() for details.

Type: Array

Allows passing of stylus plugins to be used during compile.

Type: Array

Import given stylus packages into every compiled .styl file, as if you wrote @import '...' in every single one of said files.

include css

Type: Boolean
Default: false

When including a css file in your app.styl by using @import "style.css", by default it will not include the full script, use true to compile into one script. ( NOTICE: the object key contains a space "include css" )

Type: Boolean
Default: false

Telling Stylus to generate url("bar/baz.png") in the compiled CSS files accordingly from @import "bar/bar.styl" and url("baz.png"), which makes relative pathes work in Stylus.

All urls are resolved relatively to position of resulting .css file

( NOTICE: the object key contains a space "resolve url" and Stylus resolves the url only if it finds the provided file )

resolve url nocheck

Type: Boolean
Default: false

Like resolve url, but without file existence check. Fixing some current issues.

( NOTICE: the object key contains two spaces "resolve url nocheck" )

banner

Type: String
Default: ''

This string will be prepended to the beginning of the compiled output.

relativeDest

Type: String
Default: ''

Path to be joined and resolved with each file dest to get new one. Mostly useful for files specified using wildcards:

options: {
  relativeDest: 'out'
},
files: [{
  src: ['src/components/*/*.styl'],
  ext: '.css'
}]

will generate src/components/*/out/*.css files.

Examples

stylus: {
  compile: {
    options: {
      paths: ['path/to/import', 'another/to/import'],
      relativeDest: '../out', //path to be joined and resolved with each file dest to get new one.
                              //mostly useful for files specified using wildcards
      urlfunc: 'data-uri', // use data-uri('test.png') in our code to trigger Data URI embedding
      use: [
        function () {
          return testPlugin('yep'); // plugin with options
        },
        require('fluidity') // use stylus plugin at compile time
      ],
      import: [      //  @import 'foo', 'bar/moo', etc. into every .styl file
        'foo',       //  that is compiled. These might be findable based on values you gave
        'bar/moo'    //  to `paths`, or a plugin you added under `use`
      ]
    },
    files: {
      'path/to/result.css': 'path/to/source.styl', // 1:1 compile
      'path/to/another.css': ['path/to/sources/*.styl', 'path/to/more/*.styl'] // compile and concat into single file
    }
  }
}

Release History

  • 2016-03-08   v1.2.0   Stylus ^0.54.
  • 2016-03-04   v1.1.0   Add "resolve url nocheck". Fixes #146. Remove peerDeps. Point main script to task.
  • 2016-01-19   v1.0.0   Bump stylus to 0.53.
  • 2015-07-21   v0.22.0   Add relativeDest option. Bump stylus to 0.52.
  • 2015-03-09   v0.21.0   Bump stylus to 0.50.
  • 2014-09-22   v0.20.0   Bump stylus to 0.49.
  • 2014-08-26   v0.19.0   Bump dependencies. Bump stylus to 0.48.
  • 2014-07-02   v0.18.0   Bump stylus to 0.47.
  • 2014-06-04   v0.17.0   Bump stylus to 0.46.
  • 2014-05-12   v0.16.0   Bump stylus to 0.45.
  • 2014-05-01   v0.15.1   Add support for rawDefine.
  • 2014-04-23   v0.15.0   Bump stylus to 0.44.
  • 2014-04-08   v0.14.0   Bump stylus to 0.43.
  • 2014-03-01   v0.13.2   Fix limit option for urlfunc. Update copyright to 2014.
  • 2014-02-27   v0.13.1   grunt.template.process is not needed.
  • 2014-02-22   v0.13.0   Adds Data URI Image Inlining options. Fix "resolve url" option. Use chalk module to colorize terminal output. Emphasize spaces in object keys in the README.
  • 2014-01-08   v0.12.0   Update to stylus 0.42.0.
  • 2013-12-02   v0.11.0   Update to stylus 0.41.0.
  • 2013-11-07   v0.10.0   Update to stylus 0.40.0 and nib 1.0.1.
  • 2013-10-20   v0.9.0   Update to stylus 0.38.0.
  • 2013-08-20   v0.8.0   Update to stylus 0.37.0 and nib to 1.0.0.
  • 2013-07-31   v0.7.0   Update to stylus 0.35.
  • 2013-07-11   v0.6.0   Update to stylus 0.33.
  • 2013-03-10   v0.5.0   Upgrade to stylus 0.32.1.
  • 2013-02-22   v0.4.1   Support stylus define option.
  • 2013-02-15   v0.4.0   First official release for Grunt 0.4.0.
  • 2013-01-23   v0.4.0rc7   Updating grunt/gruntplugin dependencies to rc7. Changing in-development grunt/gruntplugin dependency versions from tilde version ranges to specific versions.
  • 2013-01-09   v0.4.0rc5   Updating to work with grunt v0.4.0rc5. Switching to this.file API.
  • 2012-12-15   v0.4.0a   Conversion to grunt v0.4 conventions. Remove Node.js v0.6 and grunt v0.3 support. Merge grunt-stylus features (plugin loading, embedding). Remove experimental destination wildcards.
  • 2012-10-12   v0.3.1   Rename grunt-contrib-lib dep to grunt-lib-contrib.
  • 2012-09-24   v0.3.0   Options no longer accepted from global config key. Individually compile into dest, maintaining folder structure.
  • 2012-09-17   v0.2.2   Tests refactored, better watch integration.
  • 2012-09-10   v0.2.0   Refactored from grunt-contrib into individual repo.

Task submitted by Eric Woroshow

This file was generated on Fri Mar 18 2016 21:06:50.

grunt-contrib-stylus's People

Contributors

bezoerb avatar cakeinpanic avatar chrisabrams avatar cpojer avatar cspotcode avatar ctalkington avatar davidwood avatar devric avatar eddiemonge avatar futekov avatar hurrymaplelad avatar jamiebuilds avatar jasonkuhrt avatar jondum avatar luhad avatar ndmitry avatar pensierinmusica avatar radkodinev avatar sapegin avatar shama avatar simshanith avatar sindresorhus avatar spikebrehm avatar thybzi avatar tiye avatar vladikoff avatar w33ble avatar xhmikosr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grunt-contrib-stylus's Issues

Merging grunt-contrib-stylus and grunt-stylus

Few months ago I created grunt-stylus plugin. It’s not very good idea to make two similar plugins but I had reasons to do it:

  1. grunt-contrib was big and I didn’t want to include it in every project just to use single task.
  2. stylus task was quite hard to use and configure.

First reason is eliminated now. So here is a differences of this two plugins (and this is because grunt-contrib-stylus is useless for me now):

  1. Stylus’s url() function support. You can embed images as data:uri.
  2. Handling of Grunt’s --debug option. grunt-stylus didn’t stop to work in debug mode if there’re syntax error in source files. It’s very useful if you use grunt watch. It’s also toggles Stylus’s compress option.
  3. Probably nib support should be improved. I see few issues about nib. I didn’t test it myself yet but it looks like there is wrong (there was in my plugin) order of including nib and applying settings.

Maybe there is something else but there are main differences. Is it possible to include this functionality to grunt-contrib-stylus? (Of course I can implement it and send couple of pull requests but I decided to ask fist.) If grunt-stylus will be as simple to use and flexible as grunt-contrib-stylus I could deprecate grunt-stylus and there will be only one awesome plugin to work with Stylus.

urlfunc is not working into dist env

Hi,

This is my stylus config:

stylus: {
      dev: {
        options: { compress: false, relative: true, urlfunc: 'url' },
        files: { 'public/stylesheets/app.css': 'src/stylesheets/app.styl' }
      },
      dist: {
        options: { compress: true, relative: true, urlfunc: 'url' },
        files: { 'dist/stylesheets/app.css': 'src/stylesheets/app.styl' }
      }
    }

When I use urlfunc to build embedded base64 image, in dev environment works fine, but in dist the style background-image generates: stylesheets/data:image instead data:image

This is the css:

.logo {
    background-image: url('../images/logo.png');
    width: 70px;
    height: 13px;
    margin-left: 3px;
    display: inline-block;
    vertical-align: text-top;
}

Both environment the folder images exists.

Does anybody can help me?

Thanks!

Built-in functions not working for @import'ed .styl files

Hi,

I am getting this error when trying to use built-in functions like darken() or lighten() inside of files that were included dynamically using the @import statement.

It compiles without any problems when used in the main file that does the importing.

TypeError: src/client/app/style/detailsColumn.styl:8
>>     4| modalBlur = 3px
>>     5|
>>     6| .text
>>     7|     color darken(red,20)
>>  >  8|
>>     9| body.details
>>    10|     overflow-y hidden
>>    11|
>>
>> Cannot read property 'nodes' of undefined
>>     at ".text" (src/client/app/style/detailsColumn.styl:7)

The error occurs in any file that gets imported if it contains any BIFs.
Does anyone have any idea what could be the source of this error?

I am using Node.js version 0.10.22 and the latest version of this code base.

Add define method to config to allow creating variables

Feature request. My usecase is following: I'm using if-ie.styil mixin from here: https://github.com/kizu/if-ie.styl

It working the following way. You write code like this:

padding: 10px;
margin-left: 20px if not ie;
margin-left: 10px if ie; 

Then compiling, stylus checks if ie variable is set to true, or not. If it is set, then it creates css optimized for ie, else it creates css for other browsers.

So to use it most easily I'd like to be able to define ie variable from config. This way I can write one .styl file for both ie and not-ie version and just compile it twice with different settings.

Also it is usefull to change set of vendor prefixes in nib vendor mixin.

--resolve-url eats query and hash from url

style.styl:

@font-face {
  src: url("some-font.eot?#iefix&v=1");
}

Suppose some-font.eot is found at given path

$ stylus --resolve-url < style.styl

style.css:

@font-face {
  src: url("some-font.eot");
}

I would expect stylus to preserve ?#iefix&v=1 in resulting url.

watch single file and compile if a dependency changes

Hi, I can't find in the guide how to add a watch task for a single styl file and make it compile when an imported styl file has changed.

For example:

    watch: {
        stylesheets: {
            files: 'source/main.styl',
            tasks: [ 'stylesheets' ]
        },
}

If main.styl has an @import "dependency1" and I change dependency1.styl the main.styl won't be compiled like the regular stylus command-line watcher would do which would watch every changes in imported files..

Can anyone advise on this? Thanks in advance!

Broken with Grunt 0.4.0rc5

The line

      srcFiles = grunt.file.expandFiles(file.src);

throws an error now:

Warning: Object # has no method 'expandFiles' Used --force, continuing.

Errors on really basic usage. What am I doing wrong?

For some reason I can't get this plugin to work at all..

I keep getting this error: Warning: Object #<Object> has no method 'indexOf'

stylus: {
  compile: {
    files: {
      'dist/css/style.css': 'src/assets/css/style.styl'
    }
  }
}

Any ideas?

Update for compatibility with grunt 0.4.0rc5

I need someone to help update this plugin to work with grunt 0.4.0rc5.

I had to revert the whole file src-dest mappings implicit iteration abstraction per gruntjs/grunt#606, and once again, multi tasks have to iterate over this.files manually. In addition, there's a new this.filesSrc array that contains a reduced, uniqued set of all matched src files in case the task is read-only and only cares about source files.

See:

Notes:

  • A user may specify a new option nonull in addition to src to tell grunt to keep patterns or filepaths that don't actually match files. Because of this, the task shouldn't explode if a nonexistent src filepath is encountered. I handle this in the grunt-contrib-concat by warning if not grunt.file.exists but not failing the task.

Guidelines for updating / publishing this plugin:

  • Change this project's version number to one ending in "rc5" so that it's clearer that it works with grunt 0.4.0rc5. If the existing version number doesn't end in an "a" or "rc" increment the patch version. Eg, jshint went from 0.1.0 -> 0.1.1rc5
  • Ensure grunt 0.4.0rc5-compatible plugins are specified in package.json devDependencies like this (grunt-contrib-internal can be "*")
  • Update the CHANGELOG like this
  • Regenerate the README.md file via grunt.
  • Delete node_modules, run npm cache clean and re-run npm install to test.
  • Publish to npm using --tag=master (not latest)

failed to locate @import file nib.styl

sorry, i'm a bit of a noob to this.

I am trying to use nib with grunt-contrib-stylus. I have used a cut down example of your compile config:

stylus: {
  dist: {
    options: {
      compress: true,
      paths: [ 'ui/styles' ]
    },
    files: {
      'ui/dist/styles.css': 'ui/styles/index.styl'
    }
  }

And in the index.styl i have imported nib

@import 'nib'

But when I run grunt I get the following output and errors:

>> ReferenceError: gruntpath is not defined

Running "lint:files" (lint) task
Lint free.

Running "stylus:dist" (stylus) task
>> Error: ui/styles/index.styl:1
>>  > 1| @import 'nib'
>>    2| 
>>    3| @import 'variables'
>>    4| 
>> 
>> failed to locate @import file nib.styl

Thanks for your help

Sourcemap support?

Does stylus support sourcemaps at all? Does that even make sense here?

mix css and styl in source description

How can I mix css and stylus files without an extra concat task?
I'd like to do something like that:

 stylus: {
      compile: {
        options: {
          compress: true
        },
        files: {
          'dist/main.css': ["patht/to/styles/*.styl", "path/to/css/*.css"]
        }
      }
    }

Don't compile css into one line

Is there a way to not have the generated output be on one line? Is there a stylus or grunt option to be used during development work? The css is all on main.css:1.

compile: {
files: {
'<%= yeoman.app %>/css/main.css': '<%= yeoman.app %>/styl/*/.styl'
}
}

won't install on ubuntu

i cannot get this to install on Ubuntu. (solved)

Note the error claims version 0.32.0 of stylus is installed, but really the version of stylus is the version it claims it requires (0.29.0) according to the version of the stylus package (shown below). My group is using this in production and they seem to have no problems installing on Mac or Windows. I am the only one using Linux to my knowledge. Let me know if more information is required. I appreciate any suggestions or advice. I hope we can get this installed. Thanks!

I am running the following commands:

sudo npm -g uninstall stylus
sudo npm -g install stylus@'~0.29.0'
sudo npm install

sudo npm -g uninstall grunt
sudo npm -g install grunt
sudo npm install

I get the following:

npm WARN unmet dependency /home/zxcv/work/src/drc-ots/drcETesting/node_modules/grunt-contrib-stylus requires stylus@'~0.29.0' but will load
npm WARN unmet dependency /home/zxcv/work/src/drc-ots/drcETesting/node_modules/stylus,
npm WARN unmet dependency which is version 0.32.0

system info:

grep \"version\" /usr/local/lib/node_modules/stylus/package.json

shows...

  "version": "0.29.0",

and

cat /proc/version

shows...

Linux version 3.5.0-17-generic (buildd@allspice) (gcc version 4.7.2 (Ubuntu/Linaro 4.7.2-2ubuntu1) ) #28-Ubuntu SMP Tue Oct 9 19:31:23 UTC 2012

and

uname -a

shows...

3.5.0-17-generic #28-Ubuntu SMP Tue Oct 9 19:31:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

Caching support?

Caching of imports landed in stylus#0.440 and does not seem to be working in grunt-contrib-stylus. Any way to have caching enabled here?

Looks like the stylus object is re-created at each compilation.

Getting embedurl to work

Apologies if this is a support request instead of a bug report, but I can't seem to get this working and couldn't find any additional information from searching around. I have this config block in Grunt.js:

stylus: {
  production: {
    files: { 'public/css/mox.css': CSS_INPUTS },
    options: { compress: true }
  },
  debug: {
    files: { 'public/css/mox.debug.css': CSS_INPUTS },
    options: { compress: false }
  },
  options: {
    paths: [ 'views/css' ],
    url: 'embedurl',
    'import': [ 'nib' ]
  }
},

I've tried various incantations of embedurl('path/to/image.png') in my .styl file and can't seem to get it to turn into a data uri. It just prints out the literal string "embedurl('path/to/image.png')" in the output CSS. I'm also not sure of how to handle paths here; is the path relative to the location of my .styl file, the working directory of Grunt, or somewhere else?

Unexpected passed variables value through define

I'me defining global variables through define:

define: {
  test: '1px',
  $color: 'red'
}

And from this input.styl

.test {
    font-size: test;
    color: $color;
    }

I get wrong, quoted properties:

.test {
  font-size: '1px';
  color: 'red';
}

Here's an expected output:

.test {
  font-size: 1px;
  color: red;
}

Same result with lighter Stylus syntax without braces and semicolons.

simple output

I would like the option to compile all .styl files into .css files at the same location as the .styl file, just like stylus --watch /my/styles does.

Something like this:

stylus: {
  compile: {
    files: {
      '*.css' : '*.styl'
    }
  }
}

currently the above creates a file named *.css

nib not working

I use

border-radius 4px

in my .styl but it compiles out to

border-radius: 4px;

which clearly isn't using nib. How can I troubleshoot/resolve this?

stylus:
  compile:
    options:
      compress: false
    files:
      "template/css/common.css": ["template/styl/common.styl"]

# grunt stylus:compile
  • grunt-cli v0.1.11
  • grunt v0.4.2
  • grunt-stylus-contrib 1.3.8

Compile directory full of .styl files

Currently I cannot find a way to compile an entire directory of files only individual ones like so:

stylus:
    compile:
        files:
            '<%= yeoman.temp %>/styles/main.css': '<%= yeoman.app %>/styles/main.styl'

for other grunt projects I use (apologies, still learning grunt) it is possible to achieve this through the cwd/src/dest syntax like so:

autoprefixer:
    dist:
        files: [
            expand: true
            cwd: '<%= yeoman.temp %>/styles/'
            src: '**/*.css'
            dest: '<%= yeoman.temp %>/styles/'
        ]

Is there an easy way to compile a directory (and nested directories) full of .styl files into individual .css files?

install error

I think there is some sort of problem interacting with grunt-newer and grunt-express because if I npm uninstall both, then stylus installs fine.
I'm on osx 10.6.8

Macintosh:testproject jacknewt$ npm install grunt-contrib-stylus --save-dev
npm WARN package.json [email protected] No description
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
npm http GET https://registry.npmjs.org/grunt-contrib-stylus
npm http 304 https://registry.npmjs.org/grunt-contrib-stylus
npm http GET https://registry.npmjs.org/stylus
npm http GET https://registry.npmjs.org/nib
npm http 304 https://registry.npmjs.org/nib
npm http 304 https://registry.npmjs.org/stylus
npm http GET https://registry.npmjs.org/cssom
npm http GET https://registry.npmjs.org/mkdirp
npm http GET https://registry.npmjs.org/sax
npm http GET https://registry.npmjs.org/debug
npm http 304 https://registry.npmjs.org/cssom
npm http 304 https://registry.npmjs.org/mkdirp
npm http 304 https://registry.npmjs.org/sax
npm http 304 https://registry.npmjs.org/debug
npm ERR! peerinvalid The package grunt-contrib-stylus does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer [email protected] wants grunt-contrib-stylus@~0.8.0

npm ERR! System Darwin 10.8.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "grunt-contrib-stylus" "--save-dev"
npm ERR! cwd /Users/jacknewt/Dropbox/MyWebsites/testproject
npm ERR! node -v v0.10.18
npm ERR! npm -v 1.3.8
npm ERR! code EPEERINVALID
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/jacknewt/Dropbox/MyWebsites/testproject/npm-debug.log
npm ERR! not ok code 0

Compile all stylus files in a folder without concat

Is there a way to tell Grunt to compile all the Stylus files present in some folder, without specifying each file name and without concatenating them into a single file?

I have this need, because I want to keep the various Stylus files separate during development, compressing and concatenating them only later on when I deploy, using "usemin" (https://github.com/yeoman/grunt-usemin).

Unfortunately from the readme on "grunt-contrib-stylus" I couldn't figure out how to do it.

Imagine you have a folder named css/stylus containing the files a.styl, b.styl, and c.styl. If you want Grunt to compile all these files, keep them separate and put them in the css/ folder as a.css, b.css, and c.css, how can you do it without specifying each file name?

If you type

stylus: {
  compile: {
    options: {
      paths: ['path/to/import', 'another/to/import'],
    },
    files: {
      'css/main.css': 'css/stylus/*.styl'
    }
  }
}

Grunt would concatenate them all into one file (main.css).

Instead

stylus: {
  compile: {
    options: {
      paths: ['path/to/import', 'another/to/import'],
    },
    files: {
      'css/a.css': 'css/stylus/a.styl',
      'css/b.css': 'css/stylus/b.styl',
      'css/c.css': 'css/stylus/c.styl',
    }
  }
}

would need require you to individually specify each filename (which is not convenient in the first place, and even more when you need to update your gruntfile each time you create a new Stylus file).

Any ideas? Thanks!!

Feature request: add banner option

HI
Very useful plugin
Thank you
Please add banner to compile options for add comment at beginning of compiled files.

compile: {
  options:{
    banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
    compress: true
  },
  files: {
    'test.css': 'test.styl'
  }
}

I think it can very useful in compress mode.

paths option not allowing strings

documentation states paths option accepts String or Array. however, entering path as a String

stylus:
    css:
        options:
            paths:'src/styl/inc' #<====PATH AS STRING
        src:'src/styl/app.styl'
        dest:'src/css/tmp_app.css'

produces an error…

>> Object src/styl/inc has no method 'push'
Warning: Stylus failed to compile. Use --force to continue.

Aborted due to warnings.

however entering path as an Array

stylus:
    css:
        options:
            paths:['src/styl/inc'] #<====PATH AS ARRAY
        src:'src/styl/app.styl'
        dest:'src/css/tmp_app.css'

works fine…

Running "stylus:css" (stylus) task
File src/css/tmp_app.css created.

Done, without errors.

[feat] Allow forcing of syntax (indentation vs brackets)

Let me first say, I love stylus, you can mix and match whatever code style you want. That's fine, if you work alone. When working with multiple persons on css for large projects, this means "all bets are off" (regarding code style). Currently I'm working on a project with jade and coffeescript, both "pythonic" languages, as stylus states on its github page. So, Sass was the obvious choice at first (that, and webstorm didn't support the stylus syntax yet a while back).

Wouldn't it be nice to force a syntax, much like SASS / SCSS? I'm a nut about code cleanliness, so when seeing this (utterly valid .styl)

.some-class{
background-color: red
color blue;
}
.someOtherClass
  background-color green
  color: grey

Argh! Sad / angry face a-plenty.

What I was thinking of are some parameters in the task config which could determine what code style should be used, pythonic, or bracket bonanza..

Something along the lines of

syntax: "indentation"

or

syntax: "css" / "brackets"

Defaulting to both allowed of course.

Or something along those lines...

Maybe to complete this:

semiColon: "yes" / "no"
colon: "yes" / "no"

Defaulting to.. drum roll! Both allowed, in both cases.

Maybe even go further, and force camelCasing or hyphen-based definitions...

Or maybe you're thinking, shut up and build your own linter... Well, I guess that would be valid. I'm just wondering if there are more people like me on this subject.. That, and if the author would find it valid, and an addition to the task to make it configurable. If so, I'd love to create a pull request for this (although my knowledge on the subject is rather limited at this tine).

Any feedback would be greatly appreciated.

Allow empty stylus folders

I am trying to create a grunt template that can be used in different projects and I would like to define a stylus definition for files that are optional to exist or without content. It would be cool if stylus would continue executing if it has nothing to do. Right now it stops with following error:

>> Destination not written because compiled files were empty.

To me it is okay if this there needs to be a flag like "ignoreEmpty".

JSON is not loading

I have created an index.json file. This sits in the same directory as index.swig. When trying to load a property defined in index.json in index.swig, nothing happens. I have created a simple property called heading in my index.json file and am trying to load it by using:

{{ heading }}

in my swig file. Below is my swig config in Gruntfile.js and the index.json file i am loading.

swig config:

swig: {
            development: {
                init: {
                    root: "struct/swig/",
                    allowErrors: true,
                    autoescape: true
                },
                dest: "www/",
                cwd: "struct/swig/",
                src: ['**/*.swig'],
                generateSitemap: false,
                generateRobotstxt: true,   
                siteUrl: 'http://mydomain.net/',
                production: false,
                fb_appid: '1349v',
                ga_account_id: 'UA-xxxxxxxx-1',
                robots_directive: 'Disallow /',
                sitemap_priorities: {
                    '_DEFAULT_': '0.5',
                    'index': '0.8',
                    'subpage': '0.7'
                }
            }
        }

index.json

{
    "heading": "The Home Page"
}

The page renders as expected. The only thing it is missing is the JSON variable. I am not sure if I am missing a step or if there is a bug. I am fairly new to grunt and swig. Thanks for any help/direction/assistance/slap-upside-the-head that can be given.

Parsing error - grunt-contrib-stylus v0.10.0

I just updated grunt-contrib-stylus to v0.10.0 and stylesheets that compiled before with 0.9.0 just don't now.

Here is the code involved:

button[disabled]
html input[disabled]
    cursor: default

If I change this code as little as

button[disabled],
html input[disabled]
    cursor: default

it compiles fine.

Any insights on this?

Thanks!

Support for wildcards

Can this support wildcards for compilation?

as in:

{
stylus: {
    options: {
        import: ['src/*-mixin']
    }
}

Needs sub-tasks to work properly

For some weird reason grunt-contrib-stylus seems to need "sub-tasks" to work properly.

Let me write down a code example, to show what I mean.

stylus: {
  options : {
    paths: ['<%= yeoman.dev %>/styles/sections'],
    import: ['constants.styl'],
    linenos: true
  },
  files: {
    '<%= yeoman.dev %>/styles/main.css': '<%= yeoman.dev %>/styles/sections/*.styl'
  }
}

Does not work. But this instead works perfectly:

stylus: {
  options : {
    paths: ['<%= yeoman.dev %>/styles/sections'],
    import: ['constants.styl'],
    linenos: true
  },
  compile: {
    files: {
      '<%= yeoman.dev %>/styles/main.css': '<%= yeoman.dev %>/styles/sections/*.styl'
    }
  }
}

Can you please take a look at it and fix it? Thanks!!

Failed to locate @import file

Hi,

I recently updated to the latest grunt-contrib-stylus (0.12), and now I get two weird errors:

  1. a failed to locate @import file,
  2. another error that I can't quite understand (Error: app/styles/sections/constants.styl:2).

Here's what my Grunt output looks like:

Running "stylus:compile" (stylus) task
    >> Error: app/styles/sections/constants.styl:2
    >>    1| $black = #222;
    >>  > 2| $black-light = #333;
    >> 
    >> failed to locate @import file constants.styl

My constants.styl file though hasn't moved, and it's in the directory defined in paths.
Here's a copy of my Grunt configuration:

    stylus: {
      compile: {
        options: {
          paths: ['<%= yeoman.app %>/styles/sections'],
          import: ['constants.styl'],
          linenos: true
        },
        files: {
          '.tmp/styles/main.css': '<%= yeoman.app %>/styles/sections/*.styl'
        }
      }
    },

Any idea about what might be causing this bug and how to fix it? Thanks :)

failed to locate @import file nib.styl

Hello

I am having the same issue as #2

Running "stylus:compile" (stylus) task
Error: src/assets/styles/reset.styl:1
1| @import 'nib'
failed to locate @import file nib.styl

I am using version 0.13.0 and my gruntfile.js code for stylus is

stylus: {compile: {files: {css_files_bin: css_files_src} } },

    watch: {
        stylus:{
          files: 'src/assets/styles/*.styl',
          tasks: 'stylus'
        },
        livereload: {
            options: { livereload: true },
            files: [bin_styles + '*.css', bin_scripts + '*.js', 'static/*.html', '*.php', 'templates/*.php', bin_images + '**/*.*']
        }
    },

Am I missing something or didn't configure it properly?

dest option support for folder

stylus:
      options:
        paths: [
          'src/public/css/import'
        ]
      compile:
        files: [
          expend: true
          cwd: 'src'
          src: 'public/css/**/*.styl'
          dest: 'dest'  #no support
          ext: '.css'
        ]

Can this support?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.