Search code examples
javascriptnpmbabeljsminifybabel-cli

How to change babel output file extensions?


As the title says, babel --out-file-extension doesn't work.

Here is package.json :

{
  "name": "Assets",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "babel:dev": "babel --presets es2015 Scripts/src -d Scripts/js",
    "babel:min": "babel --presets minify Scripts/src -d Scripts/js --out-file-extension .min.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-cli": "^6.26.0",
    "babel-core": "^6.26.3",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-minify": "^0.5.1"
  }
}

When I run npm run babel:dev the result is : Scripts\src\main.js -> Scripts\js\main.js

But the same result happens when I run npm run babel:min, out files are minified but the extension won't change.

So What am I doing wrong here?


Solution

  • If you look at the docs for --out-file-extension, it states

    Added in: v7.8.0

    You are using Babel 6.x, so that option is not available.