[英]How to import an external CSS file into a JS bundle?
I have this config for CSS loading: 我有此配置用于CSS加载:
{
test: /\.css$/,
use: [
{loader: "style-loader"},
{
loader: "css-loader",
options: {
modules: true,
importLoaders: 1,
sourceMap: true
}
}
]
}
As can be seen above, it uses CSS modules. 从上面可以看出,它使用CSS模块。 All seems to work fine. 一切似乎都正常。
But, besides my CSS rules I create and consume in the code, there is some external CSS that comes with a 3rd party library leafletjs . 但是,除了我在代码中创建和使用的CSS规则外,还有一些第三方CSS附带的第三方库leafletjs 。
I suppose I want to just import it somehow without restructuring it as CSS modules. 我想我只是想以某种方式导入它,而不将其重组为CSS模块。
How can I do it so that to make this external stylesheet injected into my JS bundle output file? 我该如何做才能将该外部样式表注入到我的JS bundle输出文件中?
npm install leafletjs
and add includePath
option with its path: npm install leafletjs
并添加includePath
及其路径选择:
{
test: /\.css$/,
use: [
{loader: "style-loader"},
{
loader: "css-loader",
options: {
modules: true,
importLoaders: 1,
sourceMap: true,
includePath: './node_modules/path/to/your/library'
}
}
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.