Created
November 2, 2023 18:08
-
-
Save douglasjunior/c452c8e42f3eb3652504808989a3ed92 to your computer and use it in GitHub Desktop.
config/entries.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const path = require('path'); | |
// Obtém o diretório raiz do projeto | |
const appDirectory = fs.realpathSync(process.cwd()); | |
const resolveApp = relativePath => path.resolve(appDirectory, relativePath); | |
// Obtém todos os arquivos (componentes) de entrada | |
const entryFiles = fs | |
.readdirSync(resolveApp('src/entries')) | |
.filter(fileName => /\.js$/.test(fileName)); | |
const entries = entryFiles.reduce((result, fileName) => { | |
const key = fileName.replace('.js', ''); | |
return { | |
...result, | |
[key]: resolveApp(`src/entries/${fileName}`), | |
}; | |
}, {}); | |
// Exporta o array contendo o caminho para os arquivos, bem como os nomes dos componentes | |
module.exports = { | |
entries, | |
entriesNames: Object.keys(entries), | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment