Ways to incorporate fixed CSS into a Dojo 7 application such as FontAwesome

Currently, I have a Dojo 7 (Dojo 2) application that was built using the dojo-cli tool. I am now looking to enhance it by incorporating FontAwesome icons. Luckily, I have a Pro subscription that provides me with a zip file containing various folders of CSS and web font files that I would like to integrate into my project and then link to from index.html. My understanding of the Dojo build process, particularly webpack, is quite limited.

Adding the free version of FontAwesome from the CDN to src/index.html is easily achievable and works well:

<!link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.3/css/all.css" integrity="sha384-SZXxX4whJ79/gErwcOYf+zWLeJdY/qpuqC4cAa9rOGUstPomtqpuNWT9wdPEn2fk" crossorigin="anonymous">

According to the Dojo 2 tutorial found at , I can place static assets in the assets folder. Hence, I extracted the zipfile to

assets/fontawesome-pro-5.15.3-web
and attempted to link to it in src/index.html:

<link rel="stylesheet" href="assets/fontawesome-pro-5.15.3-web/css/all.min.css">

My goal is to utilize FontAwesome in the conventional manner without resorting to CSS Modules.

<i class="fas fa-question-mark"></i>

During the Dojo build process, a significant number of "copying file blah.css" messages are displayed as it duplicates the content of assets to output/dev/assets. I can see the FontAwesome files in

output/dev/assets/fontawesome-pro-5.15.3-web
, however, the build results in an error:

Html Webpack Plugin:
  Error: Child compilation failed:
  Module not found: Error: Can't resolve './assets/fontawesome-pro-5.15.3-web' in '/home/username/go/projectname/src':
  Error: Can't resolve './assets/fontawesome-pro-5.15.3-web' in '/home/username/go/projectname/src'
  
  - compiler.js:79 
    [travesty]/[html-webpack-plugin]/lib/compiler.js:79:16

I noticed that it references the path relative to

/home/username/go/projectname/src
, and since the original assets folder is one level above in the source tree, I also attempted to use a relative path in src/index.html:

<link rel="stylesheet" href="../assets/fontawesome-pro-5.15.3-web/css/all.min.css">

However, this resulted in a different failure:

Html Webpack Plugin:
  Error: /home/username/go/projectname/src/index.html:97
  module.exports = __webpack_public_path__ + "all.min.30RjDni8.css";
                   ^
  ReferenceError: __webpack_public_path__ is not defined
  
  - index.html:97 Object../assets/fontawesome-pro-5.15.3-web/css/all.min.css
    /home/username/go/projectname/src/index.html:97:18

The same issue occurred when I created an assets/simple.css file and tried to link to it using

<link rel="stylesheet" href="assets/simple.css">
, suggesting a general problem with my comprehension of webpack.

Would it be more appropriate to utilize the "static assets" method for these FontAwesome files, and if so, how can I resolve this build error? Alternatively, should I attempt to incorporate this third-party CSS library as a CSS Module, and if yes, how can I achieve that?

The problem could relate to webpack's "publicPath" concept, as discussed in https://webpack.js.org/guides/public-path/. If this is the case, I assume I need to make adjustments to my .dojorc to influence the usage of webpack during the Dojo build process.

Answer №1

Shoutout to @agubler over on the Dojo discord channel for sharing this simple fix:

<link rel="stylesheet" href="/assets/fontawesome-pro-5.15.3-web/css/all.min.css">

The solution builds and functions perfectly. Using an absolute URL feels a bit unsavory, so if anyone has a more comprehensive explanation to offer, I'd gladly designate that as the Accepted solution instead of this one :)

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

Arrangement of images in an array

Here's the scenario I'm facing. https://i.stack.imgur.com/FbAfw.jpg So, I have an array of images that I want to use to create a gallery with a specific layout. I've tried using grid and playing around with :nth-child(even) and :nth-child( ...

CSS guidelines specifically for when two classes are required to exist simultaneously

Is there a specific effect that can only be achieved when two classes are present simultaneously? For example: .positive{ color:#46a546; } .positive:after{ content: "\25b2"; } .negative{ color:#F00; } .arrow:after{ content: "\25bc"; ...

The col-md-4 class in Bootstrap does not consistently maintain a width of 33%

Currently, I am utilizing bootstrap cards in my project. The number of cards within a card-deck varies dynamically. However, I have encountered an issue where each card should occupy a width of col-md-4 (33%). Everything works fine when there are more than ...

Issue with scrolling feature in div

I am currently facing an issue with scrolling on my website. Visit this site to see the problem. When scrolling down, it causes the "hidden" part of the site to slide up. I want to achieve a similar sliding effect, but it needs to be smooth. I have attempt ...

The custom styles in Material-Table are taking precedence over all other styling, including Material UI styles, and causing icons to not

I recently started using the Material-Table component for a project I'm working on, and it's been great for managing tables with features like adding, editing, deleting, and searching rows. However, I've run into a few issues that I need hel ...

Adjust the Bootstrap row height to both occupy the full height while also being limited by the height of a designated container

Here's a puzzling question.. I've got a container with multiple rows, and I want these rows to completely fill the container's height without overflowing. I'm trying to avoid manually setting the row heights. When I add class="h-1 ...

Picture appears to be off-center

I created a loginPage.php file with the following content: <?php //some php stuff ?> <!DOCTYPE html> <html> <head> <title>Login Form Design</title> <link rel="stylesheet" type="text/css" href="stylelogin.c ...

Can anyone suggest a stellar sprite generator for me?

I am in search of a sprite generator to streamline my web development process. With so many options available, I am seeking recommendations for the best tool. Ideally, I want a generator that can produce both a sprite image and corresponding CSS files wi ...

Learn how to apply CSS styles from one component to another in Angular

I am attempting to modify the background color of a wrapper from a different component. I tried using ::ng-deep but it's not functioning correctly. For the mauto component, the background should be a solid block color. For the vgud component, the back ...

The button is not centered within the grid container

I need assistance centering the button within a Grid layout using Material-UI <Grid container style={{backgroundColor:'green'}} alignItems="center" justify="center" > <Grid alignItems="center" justify=&q ...

Customizing a material-ui theme with withStyles() in conjunction with withTheme()

After developing a series of reusable components, I started styling them by utilizing classes prop to override the MUI classnames. To streamline the process and prevent repetition in more intricate components, I consolidated common styles into a theme. Eac ...

Step-by-step guide on applying a universal CSS class to every component within an application

I am in the process of building a multilingual react application and I am looking for a solution to dynamically apply certain CSS styles to most components based on the chosen language. I am seeking something akin to direction-rtl and direction-ltr, whic ...

Maintaining alignment between the site content and the navbar items is a key feature of Bootstrap

I am struggling to align the brand and dropdown menu on the right with the content of my page. My goal is to have a single column for the content, taking up col-8 on larger devices and col-12 on smaller devices. I want the navbar and footer to always be 10 ...

Fade In Effect in Angular 2 Using SwitchCase

Hi everyone, I'm facing an issue with making my switch cases fade in after one is called. Here's what I have so far. When the correct switch case is entered in the input field, I want the current one to fade out and the new one to fade in. How ...

Bootstrap's landing page problem

I am currently working on creating a landing page using bootstrap and have encountered an issue with the text alignment in my section containing icons and tags. In order to make the text appear clean and concise, I want the text to be displayed in either o ...

Display a list group in two columns using Bootstrap 4's grid system

Is there a way to create a list-group with 2 columns using bootstrap 4? <div class="categories"> <h4>Categories</h4> <ul class="list-group"> <li class="list-group-item active">Name 1</li> <li clas ...

Grid items in Material UI are not positioned next to each other

I am encountering an issue with the Grid component in material-ui. The grid items are currently stacking below each other instead of beside each other, and I'm unsure of what is causing this behavior. My intention is for the grid items to stack on top ...

Modifying webpack settings for a create-react-app based project: A step-by-step guide

After starting a new react project with create-react-app, I am looking to update the webpack configuration. However, I cannot seem to locate the webpack file. Should I be creating this file myself, or is there another process involved? As someone who is ...

Attempting to use jQuery on click to set the background image of a div to a base64 encoded data image

Check out what I'm working on here The first div contains html with data:image;base64 <div id="large_photo_null" style="width:50px; height:50px; background-image: url( data:image;base64,R0lGODlhR.. );" > </div> When using html, the ba ...

Fixing a dropdown menu with multiple levels

I am attempting to create a dropdown menu with multiple levels. However, when I hover over the first level, the second level appears slightly above and to the left of the first level. I want the second level to appear directly below the first level in the ...