我希望能够在我的应用程序“src”的根目录中有一个文件夹,其中包含可重用的 css,我可以在 css 模块中编写它
在我的 css 中,我的班级没有,composes: table from './../../../css-vars/index.css';
但我试图能够使用composes: table from 'css-vars/index.css';
并让它解析到我的项目的根目录。目前,当我尝试这个时,我得到了这个错误:
Module not found: 'css-vars/index.css' in /Users/jfarina/Desktop/schedule-react/src/components/layout
这是我的 css 加载器的样子:
{
test: /\.css$/,
loaders: [
'style?sourceMap',
'css-loader?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]',
'postcss-loader'
]
},
任何想法?
我通过在我的源代码中添加路径解决了 postcss smart-import 的类似问题。css-loader 是否有类似的解决方案?我注意到有一个根查询参数,但添加并没有帮助
smartImport({
addDependencyTo: webpack,
path: [ path.resolve(__dirname, 'src') ]
})