簡體   English   中英

運行目錄中的所有文件

[英]Run all files in a directory

我想要一個配置目錄,每個配置都在一個文件中。 所以在我的 React 應用程序開始時,config 文件夾中的所有內容都會運行。 另外,如果您有更好的方法,我很高興知道😊

例如(/配置):

firebase.js

import * as firebase from 'firebase'
import 'firebase/auth'
import 'firebase/firestore'

const firebaseConfig = {
 // ...
}

firebase.initializeApp(firebaseConfig)

材料-ui.js

import coolThings from 'whatever'
// ...
export theme

你明白了

在 config 中創建一個索引文件,並在那里導入每個配置文件。 然后在主應用程序中導入配置目錄。 這樣導入的目錄將運行 index.js (config/index.js),這將運行 config 文件夾中的每個配置文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM