0

我有这个用于 CSS 加载的配置:

  {
    test: /\.css$/,
    use: [
      {loader: "style-loader"},
      {
        loader: "css-loader",
        options: {
          modules: true,
          importLoaders: 1,
          sourceMap: true
        }
      }
    ]
  }

如上所示,它使用 CSS 模块。一切似乎都很好。

但是,除了我在代码中创建和使用的 CSS 规则之外,还有一些外部 CSS 随第三方库leafletjs 一起提供

我想我想以某种方式导入它而不将其重组为 CSS 模块。

我该怎么做才能使这个外部样式表注入到我的 JS 捆绑输出文件中?

4

1 回答 1

0

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'
        }
      }
    ]
  }
于 2017-05-25T15:22:30.620 回答