Skip to content

Native support for webpack.config.coffee #475

Closed

Description

@kmalakoff

Can webpack natively read webpack.config.coffee?

Activity

  1. sokra commented on Sep 16, 2014

    @sokra
    Member

    No, sorry, but I don't want to add the coffeescript dependency for everyone.

    It's a two liner for you to use a webpack.config.coffee.

  2. akre54 commented on Sep 16, 2014

    @akre54
    Contributor

    FYI gulp gets this for free by using liftoff and node-interpret behind the scenes. There was a lot of handwringing about adding native coffee support to gulp but it was eventually added by its dependency tree.

  3. kmalakoff commented on Sep 17, 2014

    @kmalakoff
    Author

    @sokra that's fine as long as there is a way.

    Unfortunately, I couldn't figure out how to do it so I needed to compile my coffeescript file by hand which isn't good since it is unclear on which is the source.

    I tried the way is works with mocha (my only reference) with '--register/something coffee-script' but that didn't work.

    Can you please document the two liner or at least provide it in this thread for others to find?

  4. sokra commented on Sep 17, 2014

    @sokra
    Member
    // webpack.config.js
    require('coffee-script/register');
    module.exports = require("./webpack.config.coffee");
  5. kmalakoff commented on Sep 17, 2014

    @kmalakoff
    Author

    Thank you for the work around.

    I do not think this is a good solution since it pollutes the file system. I'd like something seamless and automatic like native support.

  6. andreypopp commented on Sep 17, 2014

    @andreypopp
    Contributor

    You could create your own launcher for webpack which compiles config.

  7. kmalakoff commented on Sep 17, 2014

    @kmalakoff
    Author

    @andreypopp you shouldn't need to add a bash script or write your own launcher. It should appear as native.

    I'll take @akre54 's advice look at some third party module way to pull it in like writing webpack-config-coffeescript. I didn't even think of that.

  8. lookfirst commented on Sep 21, 2014

    @lookfirst

    @sokra So lame that I have to add another file. Just make it easy for those of us who like CS. Geeez. 👎

  9. sokra commented on Sep 21, 2014

    @sokra
    Member

    Ok I would accept a PR adding node-interpret, if it doesn't add dependencies to the languages to webpack.

  10. reopened this on Sep 21, 2014
  11. pikeas commented on Oct 11, 2014

    @pikeas

    +1 to liftoff for webpack.config.coffee support.

  12. skrat commented on Dec 2, 2014

    @skrat

    If you'd use a Makefile to run webpack, it'd be very simple. I think you could also use package.json scripts, and pipe around coffee -s -c and somehow tell webpack to read the compiled .js. Unfortunately webpack doesn't support reading config.js from stdin.

  13. iboozyvoozy commented on Feb 5, 2015

    @iboozyvoozy

    No news for coffee support?

  14. added a commit that references this issue on Mar 11, 2015
    c84e587
  15. wmertens commented on Mar 11, 2015

    @wmertens
    Contributor

    Since webpack is just require-ing the config file, this needs two things:

    • The coffee-script module required before loading the config file
    • require-ing the default config as webpack.config, so that it could be a .js or a .coffee (or even a .json I think)

    Opened PR #872

  16. akre54 commented on Mar 11, 2015

    @akre54
    Contributor

    For anyone interested, this is how liftoff requires config files. I'm not familiar enough with webpack's internals but if I got pointed in the right direction I could try and whip something up.

  17. added a commit that references this issue on Mar 11, 2015
    a36916b
  18. wmertens commented on Mar 11, 2015

    @wmertens
    Contributor

    I just updated my PR so that it automagically works when the config file
    ends in .coffee as well.

    On Wed, Mar 11, 2015 at 2:31 PM Adam Krebs [email protected] wrote:

    For anyone interested, this is how liftoff requires config files
    https://github.com/tkellen/js-liftoff/blob/master/index.js#L112-L129.
    I'm not familiar enough with webpack's internals but if I got pointed in
    the right direction I could try and whip something up.

    —
    Reply to this email directly or view it on GitHub
    #475 (comment).

  19. akre54 commented on Mar 11, 2015

    @akre54
    Contributor

    The problem is your PR requires passing a --coffee flag instead of detecting the file and its extension automatically. Your code also would have to be repeated for every compile-to-js variant (TypeScript, LiveScript, etc). Is there any reason not to use node-interpret for this?

  20. wmertens commented on Mar 11, 2015

    @wmertens
    Contributor

    No go right ahead and create a PR :-) No reason why mine can't be merged
    and removed later - if you specify webpack.config.coffee as the
    configuration file it just works either way.

    On Wed, Mar 11, 2015 at 4:35 PM Adam Krebs [email protected] wrote:

    The problem is your PR requires passing a --coffee flag instead of
    detecting the file and its extension automatically. Your code also would
    have to be repeated for every compile-to-js variant (TypeScript,
    LiveScript, etc). Is there any reason not to use node-interpret for
    this?

    —
    Reply to this email directly or view it on GitHub
    #475 (comment).

  21. monder commented on Apr 6, 2015

    @monder
    Contributor

    Added PR with node-interpret

  22. wmertens commented on Apr 7, 2015

    @wmertens
    Contributor

    so now this can be closed right?

  23. nickperkinslondon commented on Aug 22, 2016

    @nickperkinslondon

    For anyone doing this...

    // webpack.config.js
    require('coffee-script/register');
    module.exports = require("./webpack.config.coffee");
    

    I would recommend using a different name for your coffee file just so it never accidentally gets compiled and over-writes your js file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions