Skip to content

Grunt and Async Writing #100

Open
Open
@jlbrooks

Description

@jlbrooks

When attempting to run css-modulesify as a browserify transform through Grunt using Grunt-browserify, an output file is generated but there is nothing written to it.

Digging into the code, I believe the issue is with the final asynchronous write here. As noted in the Grunt docs, Grunt is synchronous by default and requires you to register an async task and notify when finished. I have confirmed that changing the async write to be fs.writeFileSync(cssOutFilename, css); solves the issue.

Because this is embedded as a plugin within browserify, which is then run through the grunt-browserify plugin, I don't see an easy way to configure this correctly. Has anyone else been able to get this plugin working with a Grunt build? I'm fairly inexperienced with Grunt, so I could definitely be missing something obvious.

I've put together an example repo here. Running grunt browserify should generate the empty css file.

As far as solutions go, possibly a flag to force a synchronous write? That is, if there isn't something else I'm missing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions