[bug]:

Đang mở
#79 2 bình luận 2 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 6 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
css, react, typescript
Lĩnh vực
frontend

Hướng nghiên cứu

Start with admin/src/components/MyComponent.tsx and its imported style.css, then reproduce the issue using yarn run watch:link, yalc add strapi-plugin-name, and yarn run develop. Inspect the built plugin and Strapi Admin UI to determine why the CSS is present in dist but not applied. Done means the custom-style rules from style.css are loaded and visible in the Admin Panel.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

issue: bug
What version of @strapi/sdk-plugin are you using?

-Strapi V5
-@strapi/[email protected]
[email protected]

What's Wrong?

I'm trying to load a style.css file to customize some elements in my Strapi plugin, but the file is not being rendered or loaded in the DOM.

I've created a component with an associated CSS file and imported it into my .tsx file. When I build the project, both files are included in the dist folder, but the styles are not applied in the Strapi admin panel.

Image

Do you have any suggestions on how I can properly load my CSS in Strapi?

To Reproduce
  1. Create a com1ponent with a CSS file

Add a MyComponent.tsx file inside the admin/src/components folder.
Add a style.css file inside the same folder.
Import the CSS file in the component

  1. Import css
import "./style.css";

const MyComponent = () => {
    return <div className="custom-style">This is my component</div>;
};

export default MyComponent;

Ensure the CSS file is included in the build output

3/Ensure the CSS file is included in the build output
Run "yarn run watch:link" in the plugin repository to watch for changes.

4.Run Strapi and check the Admin UI
In a separate Strapi project, install the plugin via yalc add strapi-plugin-name.
Start Strapi with "yarn run develop".
Navigate to the plugin interface in the Strapi Admin Panel.
Observe that the styles from style.css are not applied.

Expected Behaviour

The style.css file should be loaded and applied to the component in the Strapi Admin Panel.

Ngôn ngữ chính
TypeScript
Star
24
Fork
13
Merge trung bình
5 ngày 3 giờ
Pull request đã merge (30 ngày)
5

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của strapi/sdk-plugin

Tất cả issue của strapi/sdk-plugin

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.