Can I minify an open file?

I can run an external tool on a file and pass it arguments to output to a new file. Boom. Minified. Everything there is great.

But I want to create an option called "Inline Minify", where it just minifies the contents of the opened/active tab and outputs the content into that tab (without saving)

Is this possible? Like "Send external tool output to current tab buffer" or something.

0

Hi there,

>where it just minifies the contents of the opened/active tab and outputs the content into that tab (without saving)

Not really.

IDE will save file before executing External Tool. And there is no "put results back into the editor" functionality.

But you may try and configure that External Tool so it save the output into the same file. IDE will then re-read changes from disk. Or you can invoke "File | Synchronize" manually if needed. See if that will work.

0

OK. I have noticed an issue here and there (between changing Git Branches) where the IDE does not automatically detect the filesystem changes, and I have to invoke a : File | Synchronize to see the new options. But I also now note the External Tool section an option which states: Synchronize files after execution. Would doing so lose file modification history for undo? ie:

  • Edit 1
  • Edit 2
  • Edit 3
  • Save file (so filesystem is updated)
  • Perform minification (filesystem data is updated, filesystem is sync'd, minified content shows in tab)
  • YOU_ARE_HERE

At the YOU_ARE_HERE state, I won't be able to perform UNDOs in order to get back to the pre-minified state or pre-Edit state, correct? Because of the file being saved and re-synced.

0

Not super sure.

Most likely ordinary Undo (Ctrl+Z) will do nothing ... but you can always use Local History to revert back to previous Saved state.

https://confluence.jetbrains.com/display/PhpStorm/Local+History+in+PhpStorm

0

I've never come across this local history. I will read into it! 

I love coming across all these parts of PHPStorm I had previously never heard of or discovered, to find that they solve massive issues. This really is the best IDE I've ever come across. Stable as heck, and very feature rich. Your team should be proud!

0
Avatar
Permanently deleted user

There is a large tutorial project available at GitHub that covers all the basics and not-so-basics of PhpStorm: https://github.com/JetBrains/phpstorm-workshop. It comes with preconfigured Vagrant or Docker environment of your choice so you won't need to spend your time on configuring the sandbox of your own. You can either checkout/download it directly from GitHub or create a new PhpStorm Workshop Project directly from PhpStorm's File > New Project menu - it will download everything automatically.

And I would strongly advise you to check out this amazing video with tips and tricks for PhpStorm: https://www.youtube.com/watch?v=J9emzl_VmIs .

0

请先登录再写评论。