maxmilton / esbuild-minify-templates

Minify template literal strings as part of an esbuild powered build process.
MIT License
13 stars 1 forks source link

Don't use env variables for setting options #98

Closed maxmilton closed 2 years ago

maxmilton commented 2 years ago

Currently to change minification options we use MINIFY_HTML_COMMENTS and MINIFY_TAGGED_TEMPLATES_ONLY environment variables... but it doesn't feel particularly intuitive.

The reasoning behind it is the options were at first a hidden internal option just used in my personal projects. As this package is used in more places we should avoid such hacks. Passing minifyTemplates to a Promise .then() looks clean too (.then(minifyTemplates)) but probably we'll want the ability to pass in the options, something like:

...
  .then(minifyTemplates({
    taggedTemplatesOnly: true,
    removeComments: true,
  }))

and:

...
  .then(minifyTemplates())

... which would be a breaking change.

Technically it's possible to support both .then(minifyTemplates) and .then(minifyTemplates()) but that feels too magical.

maxmilton commented 2 years ago

Closing as this was fixed a while ago by https://github.com/maxmilton/esbuild-minify-templates/pull/109