Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try terser as JS minifier #268

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

try terser as JS minifier #268

wants to merge 1 commit into from

Conversation

melizeche
Copy link
Owner

just a draft, @jorgeramirez @juanhuttemann can you guys tests if this approach is valid for #261 ?
reqs:
npm install -g terser

ref:
https://django-pipeline.readthedocs.io/en/latest/compressors.html#example

@jorgeramirez
Copy link
Collaborator

@melizeche thanks!

I haven't tested it yet. But you could try using shutil package to discover the path to terser in a cross-platform way. For example

import shutil
print(shutil.which("yuglify"))
> '/Users/jorge/.nvm/versions/node/v8.9.1/bin/yuglify'

I'll check your changes soon. I also wonder if this tool does the "translating" part (ES6+ => ES5).

@melizeche
Copy link
Owner Author

melizeche commented Apr 20, 2020

it's a minifier but we don't need translate to ES5, ES6 at least const is supported since android 2.2
https://caniuse.com/#search=const
we just need not to go full ES7 features and we will be fine I think... and fuck IE
edit: I misread the comment

Copy link
Collaborator

@juanhuttemann juanhuttemann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to change the terser binary directory because I'm using nvm
After all the assets in allstatic were generated without any problem

@melizeche
Copy link
Owner Author

@juanhuttemann in theory it should work fine with env as
https://github.com/melizeche/ayudapy/pull/268/files#diff-5e96265fa524caa1877f88f3c1958635R4
but didt't work on my case

@juanhuttemann
Copy link
Collaborator

juanhuttemann commented Apr 22, 2020

@juanhuttemann in theory it should work fine with env as
https://github.com/melizeche/ayudapy/pull/268/files#diff-5e96265fa524caa1877f88f3c1958635R4
but didt't work on my case

fix to work on any platform

import shutil
...
TERSER_BINARY = shutil.which("terser")

@jorgeramirez
Copy link
Collaborator

@melizeche it works like a charm, though I used @juanhuttemann fix. I guess if you update the PR with his suggestion is good to go 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants