maxisacoder
maxisacoder

Reputation: 1758

How to define a webpack entry file using @angular/cli (angular-cli, ng cli)?

According to official docs about .angular-cli.json config file, only main, test, polyfills can be supported as webpack entry files.

How can I set a user-defined entry file, for example, "usr": "usr.ts" by defining .angular-cli.json or some other possible way?

Upvotes: 0

Views: 537

Answers (1)

user7151805
user7151805

Reputation:

The main, test, and polyfills "webpack entry files" are in the context of the Angular-CLI webpack configuration which is a 'state-of-the-art' webpack configuration. If you want to rename the entry files for your own webpack configuration, you should review the Angular-CLI official docs on 'ejecting'. A use-case of 'ng eject' is to make use of a custom user-defined webpack configuration by ejecting your application out of any Angular-CLI specific webpack configuration to decouple your app from the Angular-CLI. Once you eject you would rename the files specific to your own custom webpack configuration that is output as a result of running the command 'ng eject'. After ejecting your application from the Angular-CLI you can't utilize the Angular-CLI commands anymore; however, you could then run the corresponding 'ng serve' command by running 'npm start' to serve the app using your 'user-defined' modifications on the webpack configuration output as a result of 'ng eject'. After ejecting from the Angular-CLI you should see logged as output to the console, something to the effect:

  • "npm run build" to build.
  • "npm run test" to run unit tests.
  • "npm start" to serve the app using webpack-dev-server.
  • "npm run e2e" to run protractor.

Running the equivalent CLI commands will result in an error. You may need to run "npm install" again.

Upvotes: 2

Related Questions