posthtml-cli icon indicating copy to clipboard operation
posthtml-cli copied to clipboard

Add .mjs ES module as supported config type

Open patorpey opened this issue 4 years ago • 1 comments

This is a request to allow the use of ES module files as config files for posthtml through the CLI.

I currently have some build tools that use similar configuration files to posthtml. I have an ES module, config.mjs, that is shared among them to provide build-time string replacements (some computed) for different build flavors. It would be desirable to be able to use this config.mjs from within my posthtml config, as well (such as for use with posthtml-expressions).

Unfortunately, I can't dynamically (asynchronously) import config.mjs from my CJS posthtml.config.js. I tried converting posthtml.config.js to an ES module as well, but even explicitly declaring it with the -c option, the CLI gives:

Error: No loader specified for extension ".mjs"

If posthtml-cli could resolve posthtml.config.mjs, then existing ES modules could be leveraged by configurations using posthtml-cli.

patorpey avatar Oct 06 '21 22:10 patorpey

related https://github.com/davidtheclark/cosmiconfig/issues/224

Scrum avatar Oct 07 '21 08:10 Scrum