vue js readdir 1

vue js readdir

const result = require.context(
  '@/',
  true,
  /^.*\.$/
)
console.log(result.keys())

Here is what the above code is Doing:
1. require.context() takes 3 arguments:
– The directory to search
– Whether to search subdirectories
– A regular expression to match files against
2. The return value from require.context() is a function
3. The function takes 1 argument:
– The name of the chunk to generate
4. The function returns an object with 2 properties:
– resolve: a function that takes a request and returns the path to the module
– keys: an array of the matching requests

Similar Posts