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

Native support for webpack.config.coffee #475

Closed
kmalakoff opened this Issue Sep 15, 2014 · 21 comments

Comments

Projects
None yet
@kmalakoff

kmalakoff commented Sep 15, 2014

Can webpack natively read webpack.config.coffee?

@sokra

This comment has been minimized.

Show comment
Hide comment
@sokra

sokra Sep 16, 2014

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.

Member

sokra commented Sep 16, 2014

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.

@sokra sokra closed this Sep 16, 2014

@akre54

This comment has been minimized.

Show comment
Hide comment
@akre54

akre54 Sep 16, 2014

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.

Contributor

akre54 commented Sep 16, 2014

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.

@kmalakoff

This comment has been minimized.

Show comment
Hide comment
@kmalakoff

kmalakoff Sep 17, 2014

@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?

kmalakoff commented Sep 17, 2014

@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?

@sokra

This comment has been minimized.

Show comment
Hide comment
@sokra

sokra Sep 17, 2014

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

sokra commented Sep 17, 2014

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

This comment has been minimized.

Show comment
Hide comment
@kmalakoff

kmalakoff Sep 17, 2014

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.

kmalakoff commented Sep 17, 2014

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.

@andreypopp

This comment has been minimized.

Show comment
Hide comment
@andreypopp

andreypopp Sep 17, 2014

Contributor

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

Contributor

andreypopp commented Sep 17, 2014

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

@kmalakoff

This comment has been minimized.

Show comment
Hide comment
@kmalakoff

kmalakoff Sep 17, 2014

@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.

kmalakoff commented Sep 17, 2014

@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.

@lookfirst

This comment has been minimized.

Show comment
Hide comment
@lookfirst

lookfirst Sep 21, 2014

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

lookfirst commented Sep 21, 2014

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

@sokra

This comment has been minimized.

Show comment
Hide comment
@sokra

sokra Sep 21, 2014

Member

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

Member

sokra commented Sep 21, 2014

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

@sokra sokra reopened this Sep 21, 2014

@jiyinyiyong

This comment has been minimized.

Show comment
Hide comment
@pikeas

This comment has been minimized.

Show comment
Hide comment
@pikeas

pikeas Oct 11, 2014

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

pikeas commented Oct 11, 2014

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

@skrat

This comment has been minimized.

Show comment
Hide comment
@skrat

skrat Dec 2, 2014

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.

skrat commented Dec 2, 2014

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.

@iboozyvoozy

This comment has been minimized.

Show comment
Hide comment
@iboozyvoozy

iboozyvoozy Feb 5, 2015

No news for coffee support?

iboozyvoozy commented Feb 5, 2015

No news for coffee support?

wmertens added a commit to wmertens/webpack that referenced this issue Mar 11, 2015

Support CoffeeScript configuration files
Simply add --coffee to the webpack invocation and it will read coffeescript configuration files if available or when specified.

Doesn't add `coffee-script` dependency to webpack install, that's up to the user.

Fixes webpack#475
@wmertens

This comment has been minimized.

Show comment
Hide comment
@wmertens

wmertens Mar 11, 2015

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

Contributor

wmertens commented Mar 11, 2015

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

@akre54

This comment has been minimized.

Show comment
Hide comment
@akre54

akre54 Mar 11, 2015

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.

Contributor

akre54 commented Mar 11, 2015

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.

wmertens added a commit to wmertens/webpack that referenced this issue Mar 11, 2015

Support CoffeeScript configuration files
Simply add --coffee to the webpack invocation and it will read
coffeescript configuration files if available or when specified.
Alternatively, you can specify the config file with a .coffee suffix.

Doesn't add `coffee-script` dependency to webpack install, that's up to
the user.

Fixes webpack#475
@wmertens

This comment has been minimized.

Show comment
Hide comment
@wmertens

wmertens Mar 11, 2015

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 notifications@github.com 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).

Contributor

wmertens commented Mar 11, 2015

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 notifications@github.com 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).

@akre54

This comment has been minimized.

Show comment
Hide comment
@akre54

akre54 Mar 11, 2015

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?

Contributor

akre54 commented Mar 11, 2015

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?

@wmertens

This comment has been minimized.

Show comment
Hide comment
@wmertens

wmertens Mar 11, 2015

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 notifications@github.com 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).

Contributor

wmertens commented Mar 11, 2015

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 notifications@github.com 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).

@monder

This comment has been minimized.

Show comment
Hide comment
@monder

monder Apr 6, 2015

Contributor

Added PR with node-interpret

Contributor

monder commented Apr 6, 2015

Added PR with node-interpret

@wmertens

This comment has been minimized.

Show comment
Hide comment
@wmertens

wmertens Apr 7, 2015

Contributor

so now this can be closed right?

Contributor

wmertens commented Apr 7, 2015

so now this can be closed right?

@nickperkinslondon

This comment has been minimized.

Show comment
Hide comment
@nickperkinslondon

nickperkinslondon Aug 22, 2016

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.

nickperkinslondon commented Aug 22, 2016

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