1

I am trying import all the files matching a glob pattern using Snowpack:

import allFiles from '../static/posts/**/*.md';

In Rollup you can achieve it with rollup-plugin-glob, is there anything like that in Snowpack ecosystem?

carlosvin
  • 979
  • 9
  • 22

2 Answers2

2

Snowpack has just released support for glob importing in 3.2.1! The syntax mirrors Vite's glob import support, so code like…

const modules = import.meta.glob('./dir/*.js')

would be transformed into the following:

const modules = {
  './dir/foo.js': () => import('./dir/foo.js'),
  './dir/bar.js': () => import('./dir/bar.js')
}
Jason Kao
  • 1,024
  • 11
  • 15
0

Currently Snowpack doesn't support importing multiple files matching a glob pattern, but there is an open issue to implement this feature, so I guess this will eventually be supported.

carlosvin
  • 979
  • 9
  • 22