Skip to content

try terser as JS minifier#268

Open
melizeche wants to merge 1 commit intodevfrom
compressorTest
Open

try terser as JS minifier#268
melizeche wants to merge 1 commit intodevfrom
compressorTest

Conversation

@melizeche
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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