Closed lemonsaurus closed 4 years ago
The CSS side of this has been handled by #48, which adds an option to compress the CSS files.
We should also make the required changes to let the same option affect the JS files.
Would it be fine to add a new dependency for this? slimit
seems like it could do the job.
@JonasUJ Yep, it'd be absolutely fine to add a dependency for this.
I take it back, slimit
is outdated and can't parse the JS. I can't find any reasonable alternative
If we want this to be a setting that can be toggled on and off, we may need to bundle https://github.com/jazzband/django-pipeline with this app and then process the files through that.
Otherwise, if we were okay with just sticking minified JS right into our PyPI package, we could use something like https://github.com/evanw/esbuild and just minify when we build for release.
The first approach makes this package a little fatter by adding another dependency, while the second is lean but doesn't let the users have the flexibility of disabling the js minification, e.g. for local dev and debugging purposes.
I'm not sure which option I like best, I'm curious how big django-pipeline
is, though.
Considering we now use the minified versions provided by the extensions (see these lines), the only place we would benefit from this is in the three tiny additional script we provide.
Of course some extensions might not provide minified js, but most do, and our scripts are so tiny that minifying would have negligible effect. I think that if someone really needs this, they could just install django-pipeline themselves.
Alright, I agree. Let's consider this solved once we merge submodule_refactor to master.
Hmm, one thing we maybe could do though is let output_style
determine whether or not to get the minified JS. What do you think of that?
Let's go with maybe.
Of the extensions that provide a minified and non-minified version, the non-minified version is still a compiled version of all the extension's source files (e.g. bulma-tagsinput). Personally, for debugging purposes, this file would be of little use to me because, at first glance at least, it looks pretty obscure. To make this useful for debugging we would probably have to go and include all the source files (from the src folder and not dist) in their own <script>
tags, but then comes the problem of finding out in which order to include them to avoid dependency errors.
I don't know, maybe there's a solution I'm not seeing, but this just doesn't seem worth pursuing.
hm, I see. Well, in that case I guess I agree that it doesn't seem worth persuing. Let's consider it solved.
There should be a BULMA_SETTING that would ensure minification of js and css files, when enabled.