Running ng build for a new angular project compiles to build files. This is inconvenient as I want to access the files directly without bundling after the angular project has been built for easy editing. Is there any way to build an angular project without bundling and just keeping the original typescript and html files after the build?
Asked
Active
Viewed 1,286 times
2
-
The original typescript and html files are not destroyed by ng build. They're left there in your src directory. Use `ng serve` or `ng build --watch`, edit the source files, and the cli will rebuild automatically. – JB Nizet Dec 11 '17 at 05:51
-
Use bundling and source maps. Or you can eject the CLI project and take control of your builds. – Brandon Culley Dec 11 '17 at 14:32
-
@BrandonSørenCulley what do you mean eject the CLI project ? – Jeson Martajaya May 11 '18 at 18:10
-
@JesonMartajaya ng-cli uses webpack under the hood. It provides `eject` option to spit out the webpack config file (and ng-cli is no more the build system for your module). Once done, you will have complete power to customize the build any way you want with webpack. – Rakesh Kumar Cherukuri May 14 '18 at 08:54
-
Fyi, I created a ng-cli issue in github here: https://github.com/angular/angular-cli/issues/10811 – Jeson Martajaya May 14 '18 at 17:31
-
@JesonMartajaya You can eject an angular cli project and take control of the build process and customize it to your specifications, https://stackoverflow.com/questions/44110064/what-is-the-purpose-of-ng-eject#44110463 – Brandon Culley May 21 '18 at 15:51
-
@BrandonSørenCulley I see, `eject` may allow me to override `angular-cli` file. What is the Webpack setting to prevent bundling ? – Jeson Martajaya May 21 '18 at 18:48
1 Answers
1
ng cli (or webpack or any other js bundler) is there to bundle your source code into browser-compatible code.
That is because Typescript (guess thats the case here) can not be understood by all browsers as-is. So, you need to use a bundler to transform it to javascript.
ng-cli (or webpack for that matter) does provide a way to keep it running and watch over your source files. This is same as what you are asking for but with one difference : ng-cli (or webpack) does the incremental bundling whenever you modify your source code.
As pointed out in other comments, you can have a look at ng-cli and give it a try.

Rakesh Kumar Cherukuri
- 1,251
- 9
- 25
-
Is there a parameter that keeps typescript transpiled at their original source directory ? – Jeson Martajaya May 11 '18 at 17:57