gonzo187 gonzo187 - 3 months ago 20x
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.



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'