We can minify template output with a config change to babel
Closed this issue · 1 comments
NullVoxPopuli commented
Found this works pretty well: https://github.com/mainmatter/ember-hbs-minifier
renaming babel.config.json
to babel.config.cjs
:
'use strict';
const minifier = require('ember-hbs-minifier/hbs-minifier-plugin').createRegistryPlugin;
module.exports = {
plugins: [
'@embroider/addon-dev/template-colocation-plugin',
[
'babel-plugin-ember-template-compilation',
{
targetFormat: 'hbs',
transforms: [minifier({})],
},
],
['module:decorator-transforms', { runtime: { import: 'decorator-transforms/runtime' } }],
],
};
Docs on transforms
: https://github.com/emberjs/babel-plugin-ember-template-compilation/?tab=readme-ov-file#common-options
I kinda want to propose this behavior be default, but I don't yet know if there are any drawbacks.
The README for ember-hbs-minifier says:
Disclaimer: This is an experiment and might change in the future. Do not use this for production yet unless you understand the consequences!
which like... 🤷 it's just an AST transform.
NullVoxPopuli commented
this was implemented!