Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Pro Dev & ISV
Unanswered

Custom css file to include in react Component PCF

(0) ShareShare
ReportReport
Posted on by 18
Hi Folks, I am trying to use custom css styling with react components in PCF and trying to import the file as like we do in regular react project. However, I am getting the following error when trying to build the project. Error: You may need an appropriate loader to handle this file type, currently no loader are configured to process this file. see https://webpack.js.org/concept#loaders Also, the styling file for the component, do I need to include that in Menifest file? (I did get the error regardless..) Any help is appreaciated. Thanks
  • MichaelFP Profile Picture
    1,831 Super User 2025 Season 1 on at
    Re: Custom css file to include in react Component PCF

    I don´t think that is not ideal. Because this is the way that wabpack (that build the bundles) works. I tested updating PCF version and nothing changed. Unfortunately, until Microsoft releases a webpackconfig extension to put on the PCF outside the node_modules we need to do this way.

  • AA-22040756-0 Profile Picture
    Microsoft Employee on at
    Re: Custom css file to include in react Component PCF

    That is cool thanks! That would still require a modifying of the pcf-script dependency which is not ideal, but i believe there is no straightforward workaround for this at this point.

  • MichaelFP Profile Picture
    1,831 Super User 2025 Season 1 on at
    Re: Custom css file to include in react Component PCF

    Hi! I created a loader for use sass on PCF. Might you use the same process for the CSS files.

     

    https://github.com/michaelfp/pcf-sass-loader 

     

    My load is combined with other modules, to be able to work. My loader does the main part, which is to create .css file on the project enabling the PCF build to copy .css file named in ControlManifest file. Unfortunately, I didn't find a way to not inform the CSS file in the manifest, because the file is read on the first part of the build process. 


    I hope this project helps you.

  • ScottDurow Profile Picture
    1,039 on at
    Re: Custom css file to include in react Component PCF

    Hi @ben-thompson  - that's interesting. I've not seen this behaviour - I use inline styles with React quite a bit where there is dynamic styling and it works on the iOS and Android D365 and PowerApps native apps. Could you post some code that doesn't work for you and I'll give it a go this end! Would be good to get to the bottom of this.

  • Ben Thompson Profile Picture
    1,400 on at
    Re: Custom css file to include in react Component PCF

    @ScottDurow  slightly off topic but of relevance is that that it seems iOS Safari completely ignores any styling added within a style attribute. Which results in some very strange results including text reverting to Times Roman and width information being completely ignored.

     

    And iOS Safari is the core component used by the D365 and PowerApp iPhone and iPad tablet apps so it's safer all round to just use CSS classes.

  • ScottDurow Profile Picture
    1,039 on at
    Re: Custom css file to include in react Component PCF

    Ah I see - the only supported way of including CSS in PCF right now is by including the css or by using inline styles - the normal webpack css loader would add the css to a style tag on the page which isn't supported by PCF.

  • alvarezskinner Profile Picture
    12 on at
    Re: Custom css file to include in react Component PCF

    If i install an NPM package to use within the control for example, if that control is using techniques to import CSS stylesheets within it, to give you an example:

     

    One of the NPM packages I'm using has the following:

     

    import 'tippy.js/dist/tippy.css'// eslint-disable-line import/extensions
    import 'tippy.js/animations/scale.css'// eslint-disable-line import/extensions
     
    This ends up throwing the following error:
     
    ERROR in ./node_modules/tippy.js/dist/tippy.css 1:0
    Module parse failed: Unexpected token (1:0)
    You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
    ERROR in ./node_modules/tippy.js/animations/scale.css 1:0
    Module parse failed: Unexpected token (1:0)
    You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
    I
    If i remove those imports, and get it in the bundle it starts failing all around... and honestly i dont believe fiddling around with NPM packages is not the best thing to do...
  • ScottDurow Profile Picture
    1,039 on at
    Re: Custom css file to include in react Component PCF

    You mean if there is some standard css that is required by a component you using and packing into your PCF bundle.js?

     

    If that's the case - you'd need to include the required css - best practice states that you should prefix the css classes with the namespace - however I can imagine if the css is very complex this wouldn't be practical.

     

    Provided the css is unique enough then the risk of it overlapping with other css is slim - but the risk will always be there!

     

  • alvarezskinner Profile Picture
    12 on at
    Re: Custom css file to include in react Component PCF

    What is the recommendation when you run into this scenario in one of your dependencies in node_modules?

    Imagine one dependency requiring another dependency, and using this approach, would you modify the file in the node_modules?

  • ScottDurow Profile Picture
    1,039 on at
    Re: Custom css file to include in react Component PCF

    As already mentioned - you will need include the css as a statically loaded file - rather than using the normal import './some.css'

     

    It's also worth mentioning that it's best practice to use the class prefix for your css based on the control name.

    So if your control name is 'myawesomepcf' and you wanted all your divs to have a red background, it would be ;

    .myawesomepcf div {
    background:red
    }
    

     

    This is because the container that the PCF is placed inside, is automatically given a class of the same name of your control (excluding the namespace).

     

    Hope this helps

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Apps - Power Apps Pro Dev & ISV

#1
WarrenBelz Profile Picture

WarrenBelz 109 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 82 Super User 2025 Season 1

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 72

Overall leaderboard