gonzo187 gonzo187 - 1 year ago 188
Node.js Question

Meteor import all files in a directory

I'm having an issue while trying to import all files in one of my directories.

This works:

import '../pages/guidance/target_access_client_relationships.js';

While this doesn't:

import '../pages/guidance';

What am I doing wrong? I am planning to have quite a lot of files in 'guidance' and I'd rather not have to import every single file individually.


Answer Source

The only way I know is to use a index.js and import all the file inside it.


dir A index.js

import './fileA.js'
import './fileB.js'

dir B  index.js

import './fileA.js'
import './fileB.js'

and finally you can make a parent dir and import both

parent dir index.js

import './dirB'
import './dirA'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download