最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to disable the default bundling in angular CLI with Angular 4 - Stack Overflow

programmeradmin3浏览0评论

I am new to webpack and angular-cli. My problem is that when I create an Angular 4 project using angular-cli, everything works fine with ng-serve but everything get bundled by default. Web pack bundling info:

I am not able to see the ponent.ts files in browser to debug. Is there any way to disable the bundling? angular-cli version details:

I am new to webpack and angular-cli. My problem is that when I create an Angular 4 project using angular-cli, everything works fine with ng-serve but everything get bundled by default. Web pack bundling info:

I am not able to see the ponent.ts files in browser to debug. Is there any way to disable the bundling? angular-cli version details:

Share Improve this question edited Apr 28, 2018 at 22:10 Kim Kern 60.5k20 gold badges216 silver badges213 bronze badges asked Jun 12, 2017 at 20:01 WebberWebber 1941 gold badge2 silver badges13 bronze badges 2
  • You can see the .ts file in the browser. You need to find the line you want in the bundle(most likely main.js). If you add a debug point there, it will use the sourcemaps to place a debug pointer in your ponent.ts file. – peinearydevelopment Commented Jun 12, 2017 at 20:27
  • Another way to acplish this in dev would be to put a debugger; statement in your ts file. – peinearydevelopment Commented Jun 12, 2017 at 20:27
Add a ment  | 

3 Answers 3

Reset to default 10

When you do ng serve with the CLI, it will create sourcemap files by default. That means, that although the source files are bundled together, you can view the original source files in the debugger and step through them. You find them in the DevTools under the tab Sources, the folder webpack://

If you want to view your prod build like this, you can add the flag -sm for sourcemaps. In the prod build, there won't be sourcemaps by default.

ng serve --prod -sm

Yes also you can enable and disable this from the developer tool option Go to setting (press F12 then F1 ). Under the source you can enable and disable to source mapping. In deploy time you not going to put the map file so this will not get downloaded. Developer tool settings

Use following build mand to hide your source code under Sources Tab

ng build --no-sourcemap ( Development environment )

ng build --env=prod --no-sourcemap (Production environment)

发布评论

评论列表(0)

  1. 暂无评论