为什么Rollup不编译我的样式组件
我很高兴我的组件lib与常规CSS一起使用,但是现在我试图添加样式的组件,突然间,我得到了错误(在正在导入LIB的项目上)
TypeError: Cannot read property 'useDebugValue' of null
styled.button
我真的尝试了所有内容,我在网上搜索了所有内容因此,但是什么都找不到。这只是令人沮丧的,希望你们能帮助我。
rolup.config.js
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import babel from 'rollup-plugin-babel'
import typescript from '@rollup/plugin-typescript';
import dts from 'rollup-plugin-dts';
import postcss from 'rollup-plugin-postcss';
const packageJson = require('./package.json');
export default [
{
input: 'src/index.ts',
output: [
{
file: packageJson.main,
format: 'cjs',
sourcemap: true,
},
{
file: packageJson.module,
format: 'esm',
sourcemap: true,
},
],
plugins: [resolve(), commonjs(), babel({plugins: ['babel-plugin-styled-components'], exclude: 'node_modules/**'}), typescript({ tsconfig: './tsconfig.json' }), postcss()],
},
{
input: 'dist/esm/types/index.d.ts',
output: [{ file: 'dist/index.d.ts', format: 'esm', sourcemap: true,
globals: { 'styled-components': 'styled' } }],
plugins: [dts()],
external: ['react', 'styled-components'],
},
];
babel.config.js
module.exports = {
presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript'],
plugins: ['babel-plugin-styled-components', {
namespace: 'appname-',
displayName: false,
fileName: false
}]
};
src/components/button/button/styles.ts
import styled from "styled-components";
export const ButtonPrimary = styled.button`
background-color: #0070f3;
border-radius: 4px;
color: #fff;
font-size: 14px;
font-weight: 500;
padding: 12px 24px;
text-transform: uppercase;
transition: background-color 0.2s ease-in-out;
&:hover {
background-color: #0060e6;
}
&:active {
background-color: #0050d6;
}
&:focus {
outline: none;
}
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
`;
我希望您能为我提供帮助,如果您需要更多信息请告诉我。
此致 knome
I was so happy that my Component Lib works with regular CSS but now I am trying to add styled components and of a sudden, I get the error (on the project which is importing the lib)
TypeError: Cannot read property 'useDebugValue' of null
styled.button
I really tried everything, I searched on the web and SO but couldn't find anything. It is just frustrating and hopefully you guys can help me.
rollup.config.js
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import babel from 'rollup-plugin-babel'
import typescript from '@rollup/plugin-typescript';
import dts from 'rollup-plugin-dts';
import postcss from 'rollup-plugin-postcss';
const packageJson = require('./package.json');
export default [
{
input: 'src/index.ts',
output: [
{
file: packageJson.main,
format: 'cjs',
sourcemap: true,
},
{
file: packageJson.module,
format: 'esm',
sourcemap: true,
},
],
plugins: [resolve(), commonjs(), babel({plugins: ['babel-plugin-styled-components'], exclude: 'node_modules/**'}), typescript({ tsconfig: './tsconfig.json' }), postcss()],
},
{
input: 'dist/esm/types/index.d.ts',
output: [{ file: 'dist/index.d.ts', format: 'esm', sourcemap: true,
globals: { 'styled-components': 'styled' } }],
plugins: [dts()],
external: ['react', 'styled-components'],
},
];
babel.config.js
module.exports = {
presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript'],
plugins: ['babel-plugin-styled-components', {
namespace: 'appname-',
displayName: false,
fileName: false
}]
};
src/components/Button/styles.ts
import styled from "styled-components";
export const ButtonPrimary = styled.button`
background-color: #0070f3;
border-radius: 4px;
color: #fff;
font-size: 14px;
font-weight: 500;
padding: 12px 24px;
text-transform: uppercase;
transition: background-color 0.2s ease-in-out;
&:hover {
background-color: #0060e6;
}
&:active {
background-color: #0050d6;
}
&:focus {
outline: none;
}
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
`;
I hope you can help me and if you need more Info please tell me.
Best Regards
Knome
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论