Can I replace systemJS by webpack with angular2

南楼画角 提交于 2019-12-07 16:48:18

问题


I understood that systemJS and webpack are doing the same. So I would like to replace systemJS by webpack but when I'm removing the system.js script reference in my html page I get the following error:

angular2.js:2 Uncaught ReferenceError: System is not defined

Does it means that angular2 is using SystemJS as module loader without the possibility to replace it by another one?


回答1:


Yes, you can.

There are few examples & tutorials.

For example:

  • https://github.com/preboot/angular2-webpack
  • https://github.com/AngularClass/angular2-webpack-starter
  • https://github.com/blacksonic/angular2-es6-starter (suggested by @blacksonic)



回答2:


remove the following script on your index.html

<script src="node_modules/systemjs/dist/system.js"></script>
or
<script src="https://code.angularjs.org/tools/system.js"></script>

then go ahead and add webpack



来源:https://stackoverflow.com/questions/36313019/can-i-replace-systemjs-by-webpack-with-angular2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!