requirejs blueimp fileuploader only loads min.js files and none other

柔情痞子 提交于 2019-12-19 04:44:29

问题


so I'm a noobie to requirejs and backbone, but I'm trying to load in all the dependencies for blueimp file uploader on my local machine and not load any external scripts. here is my config.js file:

// Set the require.js configuration for your application.
require.config({

  // Initialize the application with the main application file.
  deps: ["main"],

  paths: {
    // JavaScript folders.
    libs: "../assets/js/libs",
    plugins: "../assets/js/plugins",
    vendor: "../assets/vendor",
    api : "../assets/js/libs/api",

    // Libraries.
    jquery: "../assets/js/libs/jquery",
    jqueryui: "../assets/js/libs/jquery-ui",
    lodash: "../assets/js/libs/lodash",
    backbone: "../assets/js/libs/backbone",
    handlebars: "../assets/js/libs/handlebars",
    bootstrap : "../assets/js/libs/bootstrap",
    jqueryuiwidget : '../assets/js/libs/jquery.ui.widget',
    jstemplates : '../assets/js/libs/tmpl.min',
    jsloadimage : '../assets/js/libs/load-image.min',
    jscanvastoblob : '../assets/js/libs/canvas-to-blob.min',
    iframetransport : '../assets/js/libs/jquery.iframe-transport',
    fileupload : '../assets/js/libs/jquery.fileupload',
    fileuploadfp : '../assets/js/libs/jquery.fileupload-fp',
    fileuploadui : '../assets/js/libs/jquery.fileupload-ui'
  },

  shim: {
    // Backbone library depends on lodash and jQuery.
    backbone: {
      deps: ["lodash", "jquery", "jqueryui", "api", 'jqueryuiwidget', 'jstemplates', 'jsloadimage', 'jscanvastoblob', 'iframetransport', 'fileupload', 'fileuploadfp', 'fileuploadui'],
      exports: "Backbone"
    },

    handlebars : {
        attach: "Handlebars"
    },

    api : {
        attach : "api"
    },

    bootstrap: {
      deps: ["jquery"]
    },

    // Backbone.LayoutManager depends on Backbone.
    "plugins/backbone.layoutmanager": ["backbone"]
  }

});

i know I'm not supposed to put all those other files as dependencies for backbone, but I'm just trying to get the thing to load.

what happens is, it loads without any errors, but when I look at the page it only has loaded canvas-to-blob.min.js, load-image.min.js, and tmpl.min.js.

Any thoughts why this might be? It's weird because for example if i change the path on one of the other files to be wrong, the thing will throw and error and fail as if its trying to load it. but when its the right path, it just doesn't load...


回答1:


shim: {

backbone: {
  deps: ["lodash", "jquery"],
  exports: "Backbone"
},

bootstrap: { deps: ["jquery"] },
widget: { deps: ["jquery"] },

// backbone plugins
"plugins/backbone.layoutmanager": ["backbone"], 
"lib/jquery.fileupload": ["jquery", "widget"],
"lib/jquery.fileupload-fp": ["jquery", "lib/load-image", "lib/canvas-to-blob",        
"lib/jquery.fileupload"],
"lib/jquery.fileupload-ui": ["jquery", "lib/tmpl", "lib/load-image",  
"lib/jquery.fileupload-fp"]
}

And you have to replace paths by path variables from config in define[] part of all js files I have done the same and it is working for me.




回答2:


Try using load-image instead load-image.min file from this source https://github.com/blueimp/JavaScript-Load-Image, Its works well for me :)



来源:https://stackoverflow.com/questions/12627203/requirejs-blueimp-fileuploader-only-loads-min-js-files-and-none-other

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!