custom bundle file name angular-cli

前端 未结 1 699
情话喂你
情话喂你 2021-01-29 05:15

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 w

1条回答
  •  走了就别回头了
    2021-01-29 05:56

    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

    0 讨论(0)
提交回复
热议问题