Vue.js webpack : how to get the list of files in a directory?

别来无恙 提交于 2019-12-01 19:46:07

fs is server side module. You cannot use fs in the browser, there is no solution to this, it's technically impossible.

https://github.com/vuejs-templates/webpack/issues/262

You can utilize webpack's require.context() to list files in a given directory at compile time.

https://webpack.js.org/guides/dependency-management/

const illustrations = require.context(
  '@/assets/illustrations',
  true,
  /^.*\.jpg$/
)
console.log(illustrations.keys())
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!