Is there any priority in accordance with directory hierarchy?


#1

Hello, This might be a super basic Q, but please make my doubt clear.

I need to add 3rd party JS or css quite frequently.
If , by chance, there are any duplicated function name or css definition in 3rd party JS or css,
I should spent quite a lot of time to clear those duplication out so far.

AFAIK, Meteor automatically load every file under root directory, which makes it difficult to managing JS file and cs file in case of frequent change.

Is there any easier way of eliminating duplication problem ? without manually fixing it?

Thanks in advance~


#2

The most stable way would be to wrap 3rd party utilities into packages, this way you don’t need to worry about load order and namespacing.

https://atmospherejs.com/i/publishing

About load order, you can find the rules on the meteor docs:

The JavaScript and CSS files in an application are loaded according to these rules:

Files in the lib directory at the root of your application are loaded first.

Files that match main.* are loaded after everything else.

Files in subdirectories are loaded before files in parent directories, so that files in the deepest subdirectory are loaded first (after lib), and files in the root directory are loaded last (other than main.*).

Within a directory, files are loaded in alphabetical order by filename.

These rules stack, so that within lib, for example, files are still loaded in alphabetical order; and if there are multiple files named main.js, the ones in subdirectories are loaded earlier.

#3

It seems that you gave all that I exactly want.
Great! bless you : )