提问人:nunzietor 提问时间:11/15/2023 最后编辑:nunzietor 更新时间:11/15/2023 访问量:52
如何在同一项目中使用带有 CSS 和 Module.css 的汇总
how to use rollup with css and module.css in same project
问:
我试图为我的 react(typescript) 项目制作一个库,我需要使用 rollup 来做到这一点。 在我的项目中,我使用 css 类和 module.css 类。 我使用没有模块的css文件,因为在组件中我需要覆盖外部库(React日历)的css。
这是我的rollup.config.js的样子:
import resolve from "@rollup/plugin-node-resolve";
import typescript from "@rollup/plugin-typescript";
import dts from "rollup-plugin-dts";
import externals from "rollup-plugin-node-externals";
import commonjs from "@rollup/plugin-commonjs";
import postcss from "rollup-plugin-postcss";
import svgr from "@svgr/rollup";
const packageJson = require("./package.json");
export default [
{
input: "src/library.ts",
output: [
{
file: packageJson.main,
format: "cjs",
sourcemap: true,
},
{
file: packageJson.module,
format: "esm",
sourcemap: true,
},
],
plugins: [
postcss(),
externals(),
resolve(),
commonjs(),
typescript({tsconfig: "./tsconfig.json"}),
svgr(),
],
},
{
input: "dist/esm/library.d.ts",
output: [{file: "dist/index.d.ts", format: "esm"}],
plugins: [
dts(),
externals({
exclude: "react react-dom websocket",
}),
],
},
];
我得到的错误是针对纯css类的,如下所示
[!] Error: Could not resolve './CustomCalendar.css' from dist/esm/Component/MyComponent/CustomCalendar.d.ts
Error: Could not resolve './CustomCalendar.css' from dist/esm/Component/MyComponent/CustomCalendar.d.ts
at error (/home/pc/projects/my-project/node_modules/rollup/dist/shared/rollup.js:198:30)
at ModuleLoader.handleResolveId (/home/pc/projects/my-project/node_modules/rollup/dist/shared/rollup.js:22287:24)
at /home/pc/projects/my-project/rollup/dist/shared/rollup.js:22250:26
答: 暂无答案
评论