Configuring hugo server to serve 'mjs' ES modules

Paul Kinlan

By default Hugo doesn’t serve .mjs files with the correct content type. In fact it wasn’t until recently that hugo could serve more than one file extension per mime-type. It looks like with v0.43 this has been fixed.

[mediaTypes] [mediaTypes.“text/javascript”] suffixes = [“js”, “mjs”]

Read full post.

The above code lets me serve mjs files for ES Modules with the correct mime-type (note modules need to be served with ‘text/javascript’). This is only needed for local testing, hosting is another issue :)

Paul Kinlan

Trying to make the web and developers better.

RSS Github Medium