简体   繁体   English

转换旧的应用程序以使用Webpack

[英]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.

相关问题 如何在带有单独模块的旧php网站中使用Babel或webpack - How to use Babel or webpack in a old php site with separate modules 迁移现有的RequireJS应用程序以使用Webpack - Migrate existing RequireJS app to use Webpack 如何在与Webpack捆绑的Angular 1应用程序中使用Bootstrap - How to use Bootstrap in Angular 1 app bundled with Webpack 如何使用Webpack部署Express + React应用 - How to use webpack to deploy an Express + React app 如何在网站项目和应用程序上使用 webpack - how to use webpack on a website project and app 无法使用带有webpack的Laravel 5.7刀片模板中的某些jQuery使用良好的旧JS函数-找不到方法 - Unable to use good old JS function with some jQuery in Laravel 5.7 blade template with webpack - method not found 使用webpack构建的旧骨干和木偶 - Old Backbone & Marionette built with webpack 如何将 Webpack 4 插件转换为 Webpack 5 - How to convert Webpack 4 plugin to Webpack 5 如何在Create React App中使用Webpack devServer代理 - How to use webpack devServer proxy in create react app 如何在Ionic Version 1应用程序中使用Webpack? (有可能/有替代方案吗?) - How can I use Webpack in an Ionic Version 1 app? (Is it possible/are there alternatives?)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM