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

Process through Gulp with options set and no "processedCSS" arg? #17

Closed
kezzbracey opened this issue Aug 27, 2015 · 7 comments
Closed
Labels

Comments

@kezzbracey
Copy link

Hey Morishita,

Thanks for this plugin, it's awesome!

I'm wondering if you could point me the right direction on something please?

I'm having trouble getting this setup with Gulp, while setting options, still having it work with the stream rather than an already processed file.

This works:

gulp.task('css', function () {
    var processedCSS = fs.readFileSync('./dest/style.css', 'utf-8');
    var processors = [
        lost,
        styleGuide
    ];
    return gulp.src('./src/*.css')
        .pipe(postcss(processors))
        .pipe(gulp.dest('./dest'));
});

But I've only been able to pass options if I read from an already processed file:

gulp.task('css', function () {
    var processedCSS = fs.readFileSync('./dest/style.css', 'utf-8');
    var processors = [
        lost,
        styleGuide(processedCSS, {
            name: 'Auto Style Guide',
            theme: '1column'
        })
    ];
    return gulp.src('./src/*.css')
        .pipe(postcss(processors))
        .pipe(gulp.dest('./dest'));
});

Is there a way I can set options while still having the style guide generated from the stream?

I ask as my final file will be run through cssnano so it won't have any comments in it.

FYI I did a quick test and tried swapping the parameters in your plugin so it's:

module.exports = postcss.plugin('postcss-style-guide', function (options, processedCSS ) {

With the two swapped around I was able to set options without passing a processedCSS argument like this:

gulp.task('css', function () {
    var processedCSS = fs.readFileSync('./dest/style.css', 'utf-8');
    var processors = [
        lost,
        styleGuide({
            name: 'Auto Style Guide',
            theme: '1column'
        })
    ];
    return gulp.src('./src/*.css')
        .pipe(postcss(processors))
        .pipe(gulp.dest('./dest'));
});

Is there a way already in there that I just missed?

@matype
Copy link
Owner

matype commented Aug 28, 2015

Hi, @kezzbracey

Thanks for your report. I fixed to check the type of parameters and released postcss-style-guide v0.5.0.
Please update it :)

@kezzbracey
Copy link
Author

Awesome, thanks for that!

However I just upgraded and did a test and the options are still not getting picked up I'm afraid. :-/ The theme option isn't changed, and the name doesn't show on the generated styleguide.

I added console.log(options); to check:

if (arguments[0] === 'object') {
        options = arguments[0]
    }

    console.log(options);

....and it's still comes out as 'undefined'.

@matype
Copy link
Owner

matype commented Aug 28, 2015

Oh, sorry. I will fix it.

@matype matype added the bug label Aug 28, 2015
@kezzbracey
Copy link
Author

No problem, thanks a lot! :)

@matype matype closed this as completed in ede82c7 Aug 28, 2015
@matype
Copy link
Owner

matype commented Aug 28, 2015

I fixed it! Please update to v0.5.1 :D

@kezzbracey
Copy link
Author

I spotted it and tested it right away, working perfectly!

Thanks very much for the fix. :)

Btw, the reason I'm using your plugin at the moment is as part of a tutorial I'm writing for webdesign.tutsplus.com. If you'd like to see it, it will be part of a series called "PostCSS Deep Dive" that should be out in the next couple of months or so.

@matype
Copy link
Owner

matype commented Aug 28, 2015

Wow! I'm looking forward to reading it :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants