如何將requirejs集成到流星應用程序中並使用AMD模塊,例如我的Backbone模塊? 有沒有人這樣做,並可以告訴我需要什麼步驟來實現這個工作?使用Meteor with Requirejs
11
A
回答
4
一個簡單的答案(儘管可能不是你正在尋找的那個)是你可以簡單地使用這兩個獨立的。換句話說,加載所有的流星腳本,然後開始你需要的腳本加載。您需要的腳本將能夠使用Meteor的東西,而無需通過Require的裝載器「導入」任何它。
如果你想想要必須導入它,你應該爲它創建一個Require「shim」。
0
以下是我如何在Meteor和IronRouter中加載Aloha Editor。 Aloha使用requirejs加載它的所有依賴項。
- 解壓阿羅哈分佈公共/ alohaeditor。
- 將除aloha-common-extra.css以外的所有Aloha css文件移動到client/lib/alohaeditor(不要忘記plugins文件夾中的文件)。
- 在所有的Aloha css文件中,將相對路徑轉換爲絕對路徑(用'/ alohaeditor /'替換所有'../')。
- 安裝wait-on-lib流星包。
添加下面的鉤路線:
onBeforeAction: function(pause) { // Dynamically load require.js var one = IRLibLoader.load('/alohaeditor/lib/require.js', { success: function(){ console.log('Successfully loaded require.js'); }, error: function(){ console.log('Error loading require.js'); } }); if(!one.ready()) return pause(); // Aloha settings Aloha = window.Aloha || {}; Aloha.settings = Aloha.settings || {}; Aloha.settings.baseUrl = '/alohaeditor/lib/'; Aloha.settings.plugins = Aloha.settings.plugins || {}; Aloha.settings.plugins.load = 'common/ui, common/format, common/link, common/table, common/list, common/block, common/undo, common/contenthandler, common/paste, common/commands, common/abbr'; // Dynamically load aloha.js var two = IRLibLoader.load('/alohaeditor/lib/aloha.js', { success: function(){ console.log('Successfully loaded aloha.js'); }, error: function(){ console.log('Error loading aloha.js'); } }); if(!two.ready()) return pause(); },
相關問題
- 1. Yeoman使用Backbone/Ember with requireJs
- 2. Noty with RequireJS
- 3. glMatrix 2.2.0 with RequireJS
- 4. Backbone AMD with requireJs
- 5. toastr undefined with requirejs
- 6. Bootstrap Carousel with Meteor
- 7. execSync with meteor
- 8. Favicon with Meteor?
- 9. Swiper with Meteor
- 10. RequireJs with Knockout
- 11. VideoJS with Meteor 0.8 Blaze
- 12. 加載Youtube Iframe API with RequireJS
- 13. Meteor with Blaze:我的幫手沒有使用{{#each}}循環
- 14. 加載:long,ByteBuffer和ProtoBuff with requirejs
- 15. ngTable with requirejs - ngTableParams對象不是函數
- 16. requireJS with jQuery,Masonry,&ImagesLoaded:Object [object Object] has no method'imagesLoaded'
- 17. 使用`meteor`
- 18. 使用與requirejs
- 19. 當使用requirejs
- 20. Angularjs無法使用RequireJs加載AngularJs使用RequireJs加載無法使用RequireJs
- 21. 與requirejs一起使用miso.ds
- 22. 如何使用RequireJS
- 23. 使用requirejs和retinajs
- 24. 使用requireJs和Qtip
- 25. 開始使用requirejs
- 26. 同步使用requirejs
- 27. Backbone collection使用RequireJS
- 28. 使用requirejs加載鬍子
- 29. RequireJS使用錯誤的URL
- 30. 禁止使用Meteor賬戶?
我最後一次流星(V0.4)發揮它沒有要求/ CommonJS的支持。我認爲唯一真正的選擇是編寫自己的流星包裝插件,或手動將所需文件複製到流星文件系統。 – dsummersl
https://gist.github.com/3922137 fs = __meteor_bootstrap __。require('fs') – crapthings
@machineghost:謝謝,這聽起來像一個合理的方法 –