Incorporate pug and sass into your React project for a more

Are pug/jade and sass compatible with react?

I enjoy organizing my code by separating files, and the functionality that sass and pug provide is great for this purpose.

Is there a way to integrate pug and sass into a react project?

Pug example:

doctype html
html(lang="en", dir="ltr" , xmlns="http://www.w3.org/1999/xhtml" , prefix="og: http://ogp.me/ns# fb:http://ogp.me/ns/fb#")
  head
    meta(charset="utf-8")
    link(rel="stylesheet" , href="style.css")
  body
    p.a minim tamen labore cillum aute nulla quis anim anim summis
    ul
      each val in('one','two','three')
        li
          a(href="#",target="_blank")=val

Answer №1

Absolutely, Scss can be incorporated into your React Component with the help of a suitable loader. The best option for this is the sass-loader, which can be found at: https://github.com/webpack-contrib/sass-loader By doing so, you can easily include

import './styles.scss';

The structure of your component should be in JSX (combination of HTML and JavaScript). However, pug can be utilized in your main HTML file to load your React bundle.

index.pug

body
    #root

script(src="path/to/bundle.js")

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating a TypeScript NPM package that provides JSX property suggestions and autocomplete functionality for Intellisense

I developed a compact UI toolkit and released it on the NPM registry. The library is built using strongly typed styled-components (TypeScript) and can be easily integrated into React applications. It functions perfectly after installation with npm install ...

Is there a way to execute a function once the component has finished

Is there a way to ensure a vanillaJS function is called after the component has fully rendered in React? I am encountering errors because it runs before the component loads and cannot find specific documents. How can I execute this code only after the com ...

Turning a Two Dimensional Object or Associate Array into a Three Dimensional Object using Javascript

Is there a method to transform the following: var stateDat = { ME: ['Maine',1328361], etc. }; Into this structure dynamically within a function? var stateDatHistory = { 1:[ ME: ['Maine',1328361], etc. ], 2:[ ME: ['Maine& ...

Invoking a directive function with a return value from a controller

I am working on a directive that contains a form with a simple input. I have multiple instances of this directive on the same page (index.html). Outside of these directives, there is a button that, when clicked, should gather data from all the inputs withi ...

How to utilize a Jquery loop, implement a condition, and store the results in

After using dd() in PHP, the array displayed is as follows: 1 [▼0 => "1,18,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,19,20,21,22,23,24"] I need to iterate through the array and o ...

Angular Starter Kit

When starting with Angular.js, there are various boilerplate kits available such as angular-seed, some incorporating requirejs and more. However, many of the options I've come across seem to be outdated. As a newcomer to Angular, I'm wondering if ...

Employing JavaScript to insert a JSON value as a parameter in an HTML element's attribute

In a JSON file, I have "img" properties with .jpg file paths as their values (e.g "images/image.jpg"). I am attempting to insert these values into the 'src' attribute of existing HTML elements. Below are my attempts so far: I tried creating te ...

What are the steps to recursively transform a JavaScript object?

I am currently working on recursively transforming a JavaScript object, but I have encountered an issue. The problem is: if any object key has exactly two properties - 'label' and 'value', then the value should change to the label only ...

Attempting to utilize Vue js to connect to an API

I'm currently facing difficulties while trying to access an API in order to retrieve data. As a novice in the world of vue.js and javascript, I encountered an error message saying Uncaught SyntaxError: Invalid shorthand property initializer. Unfortuna ...

Encountering an error when trying to use this.setState

I'm currently working on developing a simple react application that consists of a component. In this component, I am attempting to adjust the state when a link is clicked. However, I'm encountering an issue where the setState function is not bein ...

Inquiring about utilizing res.render and invoking functions within an EJS template

Exploring node, I created a practice function in a separate file and imported it to my server.js. With express as my framework, passing the function in the res.render object with a parameter works seamlessly. app.get('/projects', (req, res) => ...

In ES6 React, if you want to add arguments to event handlers when functions are bound in the constructor, follow these

When working with constructors in es6, it is recommended to bind functions early like so: class App extends React.Component { constructor(props) { super(props); this.handleClick = this.handleClick.bind(this); // binding done in the constructor ...

Utilizing AngularJS to achieve similar functionality to window.bind()

When trying to set the context of a function and pass it as a callback, I am following this approach: myController.myService.validateToken(param) .then( myController.myService.getToken.bind( myController.myService ) ); myController.myService.getToken ...

`Turn a photo into a circular shape by cropping it`

Even though I know that the solution involves using border-radius: 50%, it doesn't seem to be working for my situation. In my code using React/JSX notation, this is how the icon is displayed: <i style={{ borderRadius: '50%' }} className= ...

What is the best way to keep the heights of two divs in sync?

Is there a way to make two divs have the same height, even though their content determines their individual heights? I am looking for a solution that doesn't involve using a table or a parent div. I'm new to JavaScript, so I'm hoping there i ...

Tips for adjusting the vertical scroll bar width exclusively using internal CSS within react.js

I need to implement a solution to adjust the width of the scrollbar using internal CSS (CSS stored in the JavaScript object) in a React.js project. However, when trying to apply the code below, the scrollbar's width is not changing as expected. export ...

Exciting news for React developers: the latest version, React 18, has been released along with the

I have been researching and attempting to implement themes in React v18. I thought I had done everything correctly with no errors, but for some reason, my button is not displaying any styles. The code builds without any errors... What could be the missin ...

What is the best way to incorporate the 'autoskip' functionality into chartjs?

Click here for an example I've been attempting to utilize the autoSkip functionality outlined in the documentation for chart.js: Visit this link for more information on autoSkip The current issue I'm facing is that my x-axis labels are o ...

A problem with mocking arises when two modules share identical names

Within the setup.js file of Jest configuration, I have mocked two modules: jest.mock('somePath1/Translator'); jest.mock('somePath2/Translator'); Upon running tests, I encounter the following issue: jest-haste-map: duplicate manual mo ...

stop an html page from opening a new window

When using my HTML-based application, there are instances when it needs to open another URL within an iframe. However, a problem arises when the third-party URL within the iframe also opens a new window with the same content and URL. How can I prevent th ...