简体   繁体   English

将 Webpack 与 angular.js 集成

[英]Integrating Webpack with angular.js

I am trying to migrate Angular.js app to the hybrid one.我正在尝试将 Angular.js 应用程序迁移到混合应用程序。 The code was really old so at first I changed all the controllers to the components and I would like to introduce Webpack for Angular.js now before I will use ng-upgrade tool.代码真的很旧,所以一开始我把所有的控制器都改成了组件,现在我想在使用 ng-upgrade 工具之前为 Angular.js 引入 Webpack。

I already installed webpack, created a config file but I am looking through some tutorials and they are working with export modules.我已经安装了 webpack,创建了一个配置文件,但我正在浏览一些教程,他们正在使用导出模块。 The app we are changing is quite big so is there any way I could have Webpack but without exporting angular.js modules as es6 modules?我们正在更改的应用程序非常大,所以有什么方法可以让我拥有 Webpack 但不将 angular.js 模块导出为 es6 模块? Do I need to change all dependency into the import statements?我是否需要将所有依赖项更改为导入语句?

Yes.是的。 You will have to convert all that into import statements, though it does not require ES6-Modules (we chose CommonJS modules).您必须将所有这些转换为 import 语句,尽管它不需要 ES6-Modules(我们选择了 CommonJS 模块)。

When we migrated our huge AngularJS App (bower, TypeScript, global namespaces) to webpack we also necessarily had to do the step of packing everything to exported modules and migrate from bower to npm.当我们将庞大的 AngularJS 应用程序(bower、TypeScript、全局命名空间)迁移到 webpack 时,我们还必须执行将所有内容打包到导出模块并从 bower 迁移到 npm 的步骤。

However, the whole change was less effort than we feared before, and we never regretted our decision.然而,整个改变没有我们之前担心的那么努力,我们从不后悔我们的决定。 :-) :-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM