[英]Convert old app to use webpack
I'm trying to convert my application to use webpack as it's becoming a pain to manage all the dependencies. 我正在尝试将我的应用程序转换为使用webpack,因为管理所有依赖项变得很痛苦。 I've got the vendor files compiling OK. 我已经编译了供应商文件,确定。
I have the file below ( this is a big file but I've removed alot for simplicity ) and I want to import this in my entry points. 我在下面有文件(这是一个大文件,但是为了简单起见,我已经删除了很多文件),我想在入口点导入它。 Whatever I try I get App.init is not a function. 无论我尝试什么,我都会得到App.init不是一个函数。 How would I go about converting this into a module and still act like it is doing? 我将如何将其转换为模块,并且仍然像现在一样工作? eg App.someFunction()
例如App.someFunction()
var App = function() {
// IE mode
var isRTL = false;
var isIE8 = false;
var isIE9 = false;
var isIE10 = false;
var resizeHandlers = [];
var assetsPath = '/v1/assets/';
// theme layout color set
var brandColors = {
'blue': '#89C4F4',
};
// initializes main settings
var handleInit = function() {
//do stuff
};
// Handlesmaterial design checkboxes
var handleMaterialDesign = function() {
//do stuff
}
// Handles custom checkboxes & radios using jQuery iCheck plugin
var handleiCheck = function() {
//do stuff
};
//* END:CORE HANDLERS *//
return {
//main function to initiate the theme
init: function() {
//IMPORTANT!!!: Do not modify the core handlers call order.
//Core handlers
handleInit(); // initialize core variables
//UI Component handlers
handleMaterialDesign(); // handle material design
},
//main function to initiate core javascript after ajax complete
initAjax: function() {
handleiCheck();
},
//init main components
initComponents: function() {
this.initAjax();
},
};
}();
jQuery(document).ready(function() {
App.init(); // init metronic core componets
});
Try converting App
to a common.js
module. 尝试将App
转换为common.js
模块。 Inside app.js
: 内部app.js
:
exports.App = function() {
...
}
and then import it inside your index file: 然后将其导入到索引文件中:
var App = require('path/to/app.js');
jQuery(document).ready(function() {
App.init();
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.