discharge v2.0.1 Release Notes

Release Date: 2019-05-17 // over 2 years ago

Previous changes from v2.0.0

  • 💥 Breaking change!

    TL;DR : Discharge no longer supports the “directory indexes” format. Configure your static generator to output files in the default way rather than “directory indexes”. Discharge also no longer has an option for configuring “trailing slashes” (a poor name for clean URLs). The option will automatically be removed from your configuration the next time you deploy and Discharge will upload HTML files both with and without extensions—use whichever URL style you prefer!

    Right now if you want to use the “no trailing slashes” (clean URLs) option, Discharge expects your static HTML files to be structured and named in the “directory indexes” format.

    🚀 The directory indexes format is where an HTML file that would normally be named projects.html is structured as projects/index.html. Then when Discharge deploys your files to S3, it will lop the /index.html part of the filename off, leaving just projects. This lets S3 serve the projects file when a request comes in for the path /projects.

    🚀 In retrospect, requiring that files be generated in the directory indexes format was a mistake. As you might be able to tell, if Discharge is going to transform the files anyways when deploying to S3, it doesn’t really matter how the files are structured. Discharge could take projects.html and lop the .html off just as well as it could take projects/index.html and lop the /index.html off. There is no difference.

    🚀 The reason why this was a mistake is that this places a hard requirement on a static site generator to be able to output files in a very specific way, which not all can. Fundamentally, how a URL maps to a static file isn’t really a concern of static site generators, it’s a concern of the static file host. S3 serves files one way, Netlify serves files a different way, etc. Not mandating that static site generators output files in a specific structure will allow Discharge to deploy static sites built by more static site generators.

    This change also has some additional, unexpected benefits. If you want to use clean URLs, you can’t only upload the HTML file without the .html extension, because there are scenarios in which you might need to have an HTML file in your site that is consumed by a third-party service that you don’t control and it’s specifically requesting the file with the .html extension.

    💅 That means no matter which URL style you want to use, Discharge will still have to upload a version of the file with the .html extension. That makes the difference between the clean URL configuration options so small that it obviates the need for that configuration option altogether. It’s easier to just upload two copies of every HTML file (one with the extension and one without) and everyone can use whatever URL style they prefer.