【发布时间】:2017-03-27 10:32:49
【问题描述】:
我正在开发一个 AngularJS 应用程序,我目前正在使用 SystemJS 进行模块加载。在我开始该项目一段时间后,我才知道有 Webpack。而且我还想了解什么是模块加载,我的项目如下树:
-client
-app
-components
-models
-modules
*app.--.ts (app level ts files) eg. app.module.ts
-bower_components
-node_modules(client side packages)
-js,styles,images (assets directories, same level in tree)
-typings
-index.html
-package.json
-systemjs.conf.js
-tssonfig.json
-typings.json
-server
-node_modules(server side packages)
-packages.json
-server.js
-.bowerrc
现在我看到 google 已经迁移到 Webpack,我也想使用 Webpack。我知道 Angular CLI,我已经尝试过并且成功了。
那么我是否必须创建一个新的 CLI 项目,然后将我的文件迁移到该项目?
如果我这样做,我必须特别查看哪些配置文件会影响我的应用程序在 Webpack 中的运行?
如果我继续使用 systemJS,它是否是一个可以完成大部分 Webpack 工作的工具?
或者有没有更好的方法来做到这一点,我寻求有关如何以正确和最佳方式进行迁移的建议?我仍然是一名学习者,如果有任何帮助,我将不胜感激。
假设我只想在没有 CLI 的情况下使用 Webpack,我是否只需要 webpack.config.js 并删除 systemjs.config.js 文件并删除 index.html 中的以下内容
<script src="systemjs.config.js"></script>
<script>
System.import('app').catch(function(err){ console.error(err); });
</script>
因为我目前有第三方库,我使用 systemjs 像
// other libraries
'rxjs': 'npm:rxjs',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
'angular2-google-maps/core': 'npm:angular2-google-maps/core/core.umd.js',
'ng2-page-scroll/ng2-page-scroll': 'npm:ng2-page-scroll/bundles/ng2-page-scroll.umd.js'
将这些包含在 Webpack 中对我来说是否容易,他们是否涉及使用 Webpack 官方网站中的第三方库?
谢谢。
【问题讨论】:
标签: angularjs webpack systemjs es6-module-loader