如何更改Meteor加载Javascript文件的顺序? [英] How do I change the order in which Meteor loads Javascript files?
问题描述
foo.js
和 bar.js
。 文件 bar.js
实际上包含代码, code> foo.js 但Meteor正在 foo.js $ c $之前加载
bar.js
c>,打破项目。
- 在 node.js 中,我只需使用
$
foo.js
- 在浏览器中的require('./ bar') / strong>,我会把一个
< script>
标签指向foo.js
,另一个,之后,指向到bar.js
,以便以正确的顺序加载文件。
我们如何在流星中这样做?
根据Meteor文档,文件目前按此顺序加载:
- [project_root]中的文件/ lib首先加载
- 文件按目录深度排序。
- 文件按字母顺序排列。
- 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')
insidefoo.js
- In the browser, I would put a
<script>
tag pointing tofoo.js
and another, after, pointing tobar.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:
- Files in [project_root]/lib are loaded first
- Files are sorted by directory depth. Deeper files are loaded first.
- Files are sorted in alphabetical order.
- main.* files are loaded last.
Source: http://docs.meteor.com/#structuringyourapp
这篇关于如何更改Meteor加载Javascript文件的顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!