Minify Css and Js
12. August 2022
12. August 2022
You can configure a File Watcher in the PhpStorm settings (Ctrl + Alt + S) > Tools > File Watchers. There you can add a new SCSS File Watcher and add
Program: sass
Arguments: --style=compressed $FileName$:../../Public/Css/$FileNameWithoutExtension$.min.css
For minifying JavaScript install terser via
sudo npm install -g terser
After that you can add the following code to the scripts part of the composer.json and execute it via composer minifyjs.
"minifyjs": "cd packages/template/Resources/Public/JavaScript && for file in `pwd`/*.js; do terser $file -m -c > `basename $file .js`.min.js; done && rm *.min.min.js || true"