knowledgecenter-breadcrum

Knowledge Center

28 Aug, 2020

How to include custom CSS File in React PCF Control?

Posted on 28 Aug, 2020 by Admin, Posted in Dynamics 365 Power Platform Dynamics-365 Sales

How to include custom CSS File in React PCF Control? Blogs

How to include custom CSS File in React PCF Control?

Introduction

In the previous blog, we have seen the how-to setup the react in PCF control. Now, in this blog, we will see how we can configure custom “.CSS” file in React PCF Control Project.

Problem

If we directly add the CSS file in project and after running the build command, we get below error:

For e.g. I have a created a below PCF control project, and I want to use the custom CSS from “CSS file” in same project.

Now, to use the CSS from custom file, I have added the Custom “style.css” file as shown below:

But, when I run build command in VS2019 command prompt, then I get error as “You may need an appropriate loader to handle this file type.

Solution

To resolve the above issue please follow below steps:

  1. Go to, nodemodules > PCFscript > webpackConfig.js
  2. In the “WebpackConfig.js” file, add below content:

Content

{
  test: /\.css$/,
  use: [ 'style-loader', 'css-loader']
}

WebpackConfig.js

Under “getWebpackConfig” function add above content as show below:

  1. After updating above file, run below command in “VS2019” command prompt:

npm i css-loader style-loader – -save-dev

After this, now we can use the external CSS file in our PCF Control Project.

 

 

 

Comment

This is a Required Field

Loading

Recent Updates

Blogs
07 Sep, 2023

Optimizing Storage with SubscriptionTrackingDeletedObject Cleanup

What is SubscriptionTrackingDeletedObject? The "SubscriptionTrackingDeletedObject" table is linked to the "DeletionService," which handles two types of cleanup: organization-wide and record-specific.…

READ MORE
Blogs
05 Sep, 2023

How to create real-time customer journeys in Dynamics 365 Marketing

Introduction: This blog will show how to create real-time customer journeys in Dynamics 365 Marketing. Customer journeys can be either…

READ MORE
Blogs
30 Aug, 2023

D365 CUSTOMER SERVICE: CUSTOMER 360 COMPONENT

Introduction: In Dynamics 365 (D365) Customer Service, the 'Customer 360' Component provides a comprehensive view of information and enables users…

READ MORE