【问题标题】:Conditionally load internal assets in Meteor有条件地在 Meteor 中加载内部资产
【发布时间】:2014-04-01 02:13:58
【问题描述】:

有没有办法防止自动加载我的 /client 文件夹中的所有资产?

我正在查看我的登录页面使用不同的 css/js 文件而不是我的注册或查看用户文件夹的情况。最好的方法是什么?

我最接近解决方案的是this,但这仍然不能解决我的问题。

或者最好的方法是在外部托管我的文件,然后使用条件语句使用external-file-loader

【问题讨论】:

    标签: meteor


    【解决方案1】:

    我刚刚发布了modules 智能包,它或多或少地为您完成了这项工作。您可以将其添加到您的项目中

    mrt add modules
    

    然后,您需要将要异步加载的所有文件的扩展名更改为.module_js.module_html(目前我们不支持css)。现在假设你的目录结构或多或少

    modules
      module1
        file1.module_js
        file2.module_js
      module2
        file1.module_js
        file2.module_js
    client
      main.js
    server
    public
    ...
    

    最初只有main.js 会出现在您的应用程序中。要为客户端加载其他代码,请使用异步 require 调用:

    require('module1', function () {
      console.log('the files contained in module1 folder are now loaded');
    });
    

    【讨论】:

    • 似乎是我正在寻找的,将检查模块的更新(css)。 Github 链接?
    • 您可以在 repo here 上查看,也可以在 atmosphere 上轻松找到它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-31
    相关资源
    最近更新 更多