forge icon indicating copy to clipboard operation
forge copied to clipboard

[6.x] Webpack: Support configs written in non-JavaScript

Open G-Rath opened this issue 6 years ago • 3 comments

  • [x] I have read the contribution documentation for this project.
  • [x] I agree to follow the code of conduct that this project follows, as appropriate.
  • [x] I have searched the issue tracker for an issue that matches the one I want to file, without success.

Please describe your issue:

Webpack supports using config files written in other languages (such as typescript & coffeescript) without the need to compile those files into JS, provided the right tools are installed.

For example, doing webpack will work with webpack.config.ts provided ts-node is installed.

These details are documented (here)[https://webpack.js.org/configuration/configuration-languages/].

It would be great if @eletron-forge/webpack supported this.

Currently, if I have a .ts webpack config, it doesn't get run though ts-node.

An acceptable compromise for me at this point would be to have some of pre-use hook that I could trigger compiling from; for example, being able to pass an npm command like npm run build-configs to compile my configs before they're used.

G-Rath avatar Feb 14 '19 23:02 G-Rath

I think right now the workaround is to write a shim script that calls ts-node programmatically with your config file.

I think this is a good feature for someone to contribute to Forge. It looks like based off of your link, webpack uses node-interpret to determine how to execute the config file?

I believe this sort of logic would go here:

https://github.com/electron-userland/electron-forge/blob/788412e38cfb7a0efa7202a39d45e47c78b4118b/packages/plugin/webpack/src/WebpackPlugin.ts#L41-L44

malept avatar Feb 15 '19 00:02 malept

I think right now the workaround is to write a shim script that calls ts-node programmatically with your config file.

Yes, something like that - The thing I'd wanted to avoid is having to do npm run build-configs && electron-forge x everywhere.

I think this is a good feature for someone to contribute to Forge.

I was meaning to stick at the end that I'd be interested in having a whack at it if I manage to find some free time, if it sounded like something that could be viable & someone pointed me in the right direction :)

Thanks for the better title - I'm got a bit going on right now, that's got me frazzled so sorry if some of my sentences don't make a lot of sense 😂

G-Rath avatar Feb 15 '19 00:02 G-Rath

#905 suggests adding support for returning a function, then at least you could run the parser yourself and return the json.

thomassuckow avatar Jun 24 '19 18:06 thomassuckow

closed in https://github.com/electron/forge/pull/3012

erickzhao avatar Oct 31 '22 23:10 erickzhao