[英]What would be the recommended way to collect “global styles” into an index file?
[英]What is the recommended way to include a global module with Webpack?
我正在使用Webpack開發一個大型應用程序,其中包括所有其他模塊都需要訪問的全局settings.js
文件。 而不是import settings from '../path/to/settings';
添加import settings from '../path/to/settings';
在所有模塊的頂部,我希望有一種更簡潔的方法,使其默認情況下可用於所有模塊。
有關添加全局模塊供其他所有人使用的建議?
發現我已經使用webpack.ProvidePlugin
進行了此webpack.ProvidePlugin
。 擴展它以包括我的設置文件:
module.exports = {
resolve: {
modulesDirectories: [
'src',
'node_modules'
],
extensions: ['', '.json', '.js']
},
plugins: [
new webpack.ProvidePlugin({
settings: 'settings'
})
]
};
我的settings.js
文件位於src
內部,該文件已通過resolve
Webpack配置項進行訪問。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.