minify icon indicating copy to clipboard operation
minify copied to clipboard

Cli option for rename files to *.min.js

Open phoxer opened this issue 6 years ago • 3 comments

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 -_-

phoxer avatar Oct 26 '18 05:10 phoxer

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

evolutionxbox avatar Dec 10 '18 15:12 evolutionxbox

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

filipopo avatar Jan 01 '20 21:01 filipopo

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

adamduncan avatar Mar 10 '20 14:03 adamduncan