【问题标题】:How to generate typings for css in rollup如何在汇总中为 css 生成类型
【发布时间】:2017-12-25 07:45:45
【问题描述】:

我在源代码中使用 rollup 作为我的模块构建器和 Typescript。现在,我需要为我的模块定义一些 CSS 文件。 在将我的 CSS 文件导入到 .ts 文件时,我收到以下错误 Cannot find module './styles.css'. 如何为我的 CSS 文件生成类型?

我遇到了一个 npm 包 typed-css-modules 来生成类型。我尝试使用它,但我的 CSS 类再次没有导出到我的 .ts 文件中。

【问题讨论】:

  • 你试过import './styles.css'; 吗?
  • 是的,我尝试直接导入,但我无法使用 CSS 类。
  • require('./styles.css'); 怎么样?
  • 我也试过了,还是不行。而且,在这种情况下,生成的 CSS 文件是空的。
  • 你的css文件可能有语法错误?

标签: css typescript typescript-typings rollup


【解决方案1】:

无论如何,我找到了解决问题的方法。 我现在正在使用这个包来生成 Typings

rollup-plugin-postcss-modules

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-02-03
    • 1970-01-01
    • 1970-01-01
    • 2020-08-30
    • 2018-08-04
    • 1970-01-01
    • 1970-01-01
    • 2017-03-22
    相关资源
    最近更新 更多