Incorporate a CSS framework into the Angular vendor bundle

My current situation :

The challenge I'm facing :

Integration of Semantic UI into webpack is not having any impact.

Steps I've taken so far :

(I referred to the official Angular documentation for webpack)

Added semantic-ui to package.json via terminal

npm install semantic-ui-css --save

Included a vendor bundle in the entry property of webpack.common.js

[...]
entry: {

  'polyfills': './src/polyfills.browser.ts',
  'main':      AOT ? './src/main.browser.aot.ts' :
              './src/main.browser.ts',
  'vendor':   './src/vendor.ts'

},
[...]

Created the file src/vendor.ts and included the following content :

// Angular
import '@angular/platform-browser';
import '@angular/platform-browser-dynamic';
import '@angular/core';
import '@angular/common';
import '@angular/http';
import '@angular/router';

// My CSS framework
import 'semantic-ui-css';

Results obtained :

Webpack compiled without any errors, the vendor bundle was generated :

vendor.bundle.js   3.74 MB       2  [emitted]  [big]  vendor

Additionally, webpack injected the bundle script into the HTML page :

<script type="text/javascript" src="polyfills.bundle.js"></script><script type="text/javascript" src="vendor.bundle.js"></script><script type="text/javascript" src="main.bundle.js" async></script></body>

However, there was no visual change (though I should confirm this using CDN) and the vendor.bundle.js file wasn't visible in the dist directory.

It seems like I may have overlooked something, but what could it be?

Answer №1

Here is a simple example of how to import semantic.js by referencing it in package.json.

import 'semantic-ui-css';

If you want to import the CSS file, use the following code:

// Importing CSS
import 'semantic-ui-css/semantic.css';

You can also do this in your src/styles/styles.scss file:

@import '../../node_modules/semantic-ui-css/semantic.css';

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

The image in drag and drop ghost preview is not appearing on Firefox

I want to show a ghost element instead of the default browser preview while dragging and dropping. However, in Firefox, the image inside the ghost element is not displayed during dragging. Oddly enough, if I drop it and then drag again, the image does appe ...

Angular 2 now has the ability to detect keydown events triggered from any part of the page

Is there a way to enable keyboard control for a view? I attempted using document.keydown, but it wasn't successful. How can I make the document accept keyboard input? A solution that worked for me was implementing this in my component class: @HostLi ...

Encountering compilation issues when transitioning from Angular 7 to Angular 8

Upon upgrading my project to Angular 8, an unexpected error occurs during the build process: ERROR in HostResourceLoader: loader(C:/myapp/cli/src/app/pages/user-home/user-home.component.html) returned a Promise i 「wdm」: Failed to compile. Ho ...

The script functions perfectly in jsfiddle, yet encounters issues when used in an HTML

I stumbled upon a seemingly peculiar issue with my script in jsfiddle: https://jsfiddle.net/oxw4e5yh/ Interestingly, the same script does not seem to work when embedded in an HTML document: <!DOCTYPE html> <html lang="en"> <head> & ...

Rearrange two elements by flipping their positions using CSS

I'm working with the following div that contains an input and a label: <div class="js-form-item "> <input type="checkbox" id="checkboxes-11" class="type-checkboxes form-checkbox"> <label for="option-a-checkboxes-11" class=" ...

Align content to the bottom using Bootstrap 4

Looking for help with aligning content to the middle and bottom on a full-page bootstrap layout? The first page has a background image in the first div, and a darker layer on top in the second div. <div class="h-100 w-100"> <div class="h-100 w-10 ...

The issue arises when trying to call a JavaScript function that has not been properly

Initially, write code in resources/js/app.js file function button1Clicked(){ console.log('Button 1 is clicked'); } Next, include the following code in testing.blade.php file <!DOCTYPE html> <html> <head> <meta name="cs ...

Correct placement of elements using absolute positioning and optimized scroll functionality

I am currently working on implementing tooltips for items within a scrollable list. My goals for the tooltips are as follows: Ensure they are visible outside and not restricted by the scroll area Appear immediately after the corresponding item Be detach ...

Consistent CSS alignment across all browsers

I have designed a four-digit counter that needs to be displayed in the bottom right corner of the page. Each digit is represented by a block image as a background. It is functioning properly in Chrome, but there are compatibility issues with IE7+ and Firef ...

Alignment issue with text in Vuetify Datatables cells

I'm experimenting with Vuetify on my Laravel Vue application, and everything seems to be working fine except for the DataTables styles. The padding of the cells is not vertically center aligned as expected. Here's a screenshot Interestingly, the ...

Animating the mobile menu transition using Bootstrap CSS

Can anyone help me with animating the mobile menu when I click the menu icon? This is what I have for the menu: .overlay-menu { position: fixed; display: none; z-index : 1040; width: 100vw; height: 100vh; background: rgba(0, 0,0, 0 ...

Random variable without repetition in SASS

I have a unique project where I am tasked with incorporating a list of 5 specific colors into 10 different div elements. The challenge is that each color must be used twice and in a completely random order without any repetition of colors. Although utilizi ...

Limit the amount of text displayed on the main section of the webpage

I am working on creating a simple webpage with three different sections styled like this: .top { position:absolute; left:0; right:0; height: 80px; } .left { position:absolute; ...

What are the advantages of utilizing @input and @output instead of subject/services?

When passing data between child and parent components in Angular, we often utilize @Input and @Output. What advantages do @Input and @Output offer over using subjects or services? Aside from being the most conventional method provided by Angular itself, is ...

What is the best way to sort through an array depending on a specific sequence of elements provided

I am trying to create a custom pipe in Angular 5 that filters an array of events based on a given sequence. For instance, if my data is: ["submit", "click", "go_back", "click",...] I want to filter this data based on up to three inputs. If input ...

Personalizing the predefined title bar outline of the input text field

The outline color of the title in the input textbox appears differently in Google Chrome, and the bottom border line looks different as well. <input type="text" title="Please fill out this field."> https://i.stack.imgur.com/iJwPp.png To address th ...

What is the proper way to integrate plotly types in Angular using a local version?

After exploring various plotly packages, I discovered that the angular-plotly package is no longer being updated. To incorporate the plotly library into my project, I decided to download the plotly.min.js file and include it in my sources. Additionally, I ...

Attempting to understand the findings of the npm audit

Context Upon running the npm audit command on an old ReactJS project that we recently revisited after a year, a summary of 356 vulnerabilities was obtained (321 low, 20 moderate, 14 high, 1 critical) across 11345 scanned packages. Executing npm audit fix ...

Activate the Chrome Extension that allows you to open a link in a new tab with just a middle click or regular click, without closing the popup

When I try to click a link in my extension popup and open it in a new tab using "middle click -> open link in a new tab", the popup closes. Is there a way to keep the popup open so I can click on multiple links from my extension without interruption? Any ...

Adjust the column count based on the screen size, Susy suggested

When using the Compass/Sass plugin Susy, you typically set the number of columns in the _base.scss file. I prefer to have 12 columns for a desktop view, but this may be too many columns for a mobile display. Is there a method to alter the number of column ...