Jay
Jay

Reputation: 711

custom bundle file name angular-cli

I'm using angular-cli: 1.0.0-beta.28.3 to bundle the project files. When i run ng build, it creats main.bundle.js file under dist folder.

Instead of main.bundle.js I want to give a custom name (example: myproject.js). Is there a way to provide a custom output file name when using ng build.

Upvotes: 0

Views: 3899

Answers (1)

Ahmed Musallam
Ahmed Musallam

Reputation: 9753

Unfortunately no, the bundle names cannot be configurable. There is no option for such thing in the build wiki: https://github.com/angular/angular-cli/wiki/build

however, you can run a simple nodejs script to do that for you:

// rename.js file - location, right next to package.json
var fs = require("fs");
fs.rename("./dist/main.bundle.js", "./dist/myproject.js");

then in your package.json, add a new script call it something like build-rename

"scripts":{
   "build-rename":"ng build && node rename.js"
}

now run the script npm run build-rename

Upvotes: 4

Related Questions