minify
minify copied to clipboard
Cli option for rename files to *.min.js
Hi, I am trying to rename files with cli npm but I can't is there an option for rename? example file.js to file.min.js
Using wildcards with $1 output maybe?
This is my CLI chain (package.json):
"scripts": {
"compress": "babel --presets minify *.js --out-file $1.min.js --mangle.keepClassName --no-comments"
}
this ouput $1.min.js file -_-
I don't think this is support out-of-the-box. The closest I could find, after a quick google-search, is https://www.npmjs.com/package/babel-plugin-import-rename
I made an opsie when opening an issue... nonetheless a bit late but...
for file in javascripts/*.js; do
if [ ${file: -6} != "min.js" ]; then
babel-minify $file -o "${file%.js}.min.js"
fi
done
I thought
babel-minify javascripts/*.js -o *.min.js would work
Since v7.8.0 you can use the --out-file-extension
flag?
"scripts": {
"compress": "babel --presets minify *.js --out-file-extension .min.js --mangle.keepClassName --no-comments"
}
https://babeljs.io/docs/en/babel-cli#set-file-extensions