如何更改Meteor加载Javascript文件的顺序? [英] How do I change the order in which Meteor loads Javascript files?

查看:108
本文介绍了如何更改Meteor加载Javascript文件的顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您使用Meteor框架制作项目时,它会将所有文件合并在一起,但似乎没有明确说明我希望在该文件之前加载该文件。

例如,我有两个javascript文件: foo.js bar.js



文件 bar.js 实际上包含代码, code> foo.js 但Meteor正在 foo.js bar.js c>,打破项目。




  • node.js 中,我只需使用 $ foo.js

  • 浏览器中的require('./ bar') / strong>,我会把一个< script> 标签指向 foo.js ,另一个,之后,指向到 bar.js ,以便以正确的顺序加载文件。



我们如何在流星中这样做?

解决方案

根据Meteor文档,文件目前按此顺序加载:


  1. [project_root]中的文件/ lib首先加载

  2. 文件按目录深度排序。

  3. 文件按字母顺序排列。

  4. main。*文件最后加载。 b

资料来源:
http:// docs.meteor.com/#structuringyourapp


When you make a project with the Meteor framework, it packages all the files together, but there doesn't seem to be a way to explicitly say "I want this file to be loaded before that one".

Let's say, for example, I have 2 javascript files: foo.js and bar.js.

The file bar.js is actually containing code depending one the one inside foo.js but Meteor is loading bar.js before foo.js, breaking the project.

  • In node.js I would simply use require('./bar') inside foo.js
  • In the browser, I would put a <script> tag pointing to foo.js and another, after, pointing to bar.js, in order to load the files in the correct order.

How can we do that in Meteor?

解决方案

According to the Meteor documentation, files are currently loaded in this order:

  1. Files in [project_root]/lib are loaded first
  2. Files are sorted by directory depth. Deeper files are loaded first.
  3. Files are sorted in alphabetical order.
  4. main.* files are loaded last.

Source: http://docs.meteor.com/#structuringyourapp

这篇关于如何更改Meteor加载Javascript文件的顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆