Configuring hugo server to serve ‘mjs’ ES modules

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 content originally appeared on Modern Web Development with Chrome and was authored by Paul Kinlan

<p>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.</p> <blockquote> <p>[mediaTypes] [mediaTypes."text/javascript"] suffixes = ["js", "mjs"]</p> </blockquote> <p><a href="https://github.com/PaulKinlan/paul.kinlan.me/commit/43224a694d420fa5ede1e9e6eda042a562d5a6c5">Read full post</a>.</p> <p>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 :)</p>


This content originally appeared on Modern Web Development with Chrome and was authored by Paul Kinlan


Print Share Comment Cite Upload Translate Updates
APA

Paul Kinlan | Sciencx (2018-07-20T14:17:29+00:00) Configuring hugo server to serve ‘mjs’ ES modules. Retrieved from https://www.scien.cx/2018/07/20/configuring-hugo-server-to-serve-mjs-es-modules/

MLA
" » Configuring hugo server to serve ‘mjs’ ES modules." Paul Kinlan | Sciencx - Friday July 20, 2018, https://www.scien.cx/2018/07/20/configuring-hugo-server-to-serve-mjs-es-modules/
HARVARD
Paul Kinlan | Sciencx Friday July 20, 2018 » Configuring hugo server to serve ‘mjs’ ES modules., viewed ,<https://www.scien.cx/2018/07/20/configuring-hugo-server-to-serve-mjs-es-modules/>
VANCOUVER
Paul Kinlan | Sciencx - » Configuring hugo server to serve ‘mjs’ ES modules. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2018/07/20/configuring-hugo-server-to-serve-mjs-es-modules/
CHICAGO
" » Configuring hugo server to serve ‘mjs’ ES modules." Paul Kinlan | Sciencx - Accessed . https://www.scien.cx/2018/07/20/configuring-hugo-server-to-serve-mjs-es-modules/
IEEE
" » Configuring hugo server to serve ‘mjs’ ES modules." Paul Kinlan | Sciencx [Online]. Available: https://www.scien.cx/2018/07/20/configuring-hugo-server-to-serve-mjs-es-modules/. [Accessed: ]
rf:citation
» Configuring hugo server to serve ‘mjs’ ES modules | Paul Kinlan | Sciencx | https://www.scien.cx/2018/07/20/configuring-hugo-server-to-serve-mjs-es-modules/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.