Minify: Cli option for rename files to *.min.js

Created on 26 Oct 2018  路  3Comments  路  Source: babel/minify

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

Most helpful comment

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

All 3 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

EladBezalel picture EladBezalel  路  4Comments

hzoo picture hzoo  路  5Comments

boopathi picture boopathi  路  3Comments

jamesloewen picture jamesloewen  路  3Comments

callym picture callym  路  4Comments