[英]How can I use Webpack in an Ionic Version 1 app? (Is it possible/are there alternatives?)
I've never used Webpack in an ionic project and I am trying to use it like I would in node.js
project and I'm getting the error ReferenceError: Can't find variable: require
so I seems as though I wouldn't use webpack the same way. 我从来没有在一个离子项目中使用Webpack,我试图像在node.js
项目中那样使用它,我得到错误ReferenceError: Can't find variable: require
所以我好像不会以同样的方式使用webpack。 How can I do this in my Ionic version 1 project? 我如何在我的Ionic版本1项目中执行此操作?
So far I add the bundle in my index.html
到目前为止,我在index.html
添加了bundle
<script src="app/main/myapp.bundle.js"></script>
and inside I import all my other scripts
like so 在里面我导入我所有的其他scripts
require('../common/myimport')
removing the 删除
<script src="app/common/myimport.js"></script>
in my index.html
在我的index.html
Then if I run 如果我跑了
webpack ./www/app/main/app.js ./www/app/main/myapp.bundle.js
I get that error. 我收到了这个错误。
So can I use webpack
in ionic, and if so how can I import my scripts into the bundle
? 那么我可以在离子中使用webpack
吗?如果是这样,我如何将我的脚本导入到bundle
?
Yes, you can. 是的你可以。 It is the same as for any angular 1.x application. 它与任何角度1.x应用程序相同。
I have made project template for this purpose with all required configuration files for webpack: 我为此目的制作了项目模板,包含webpack的所有必需配置文件:
https://github.com/zxbodya/angular-webpack-seed https://github.com/zxbodya/angular-webpack-seed
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.