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

When taking a vertical picture on my iPhone, my Vue component does not function properly

Having trouble with displaying recently uploaded images on a form. If the image is taken from a phone, it may have an exif property that browsers do not handle correctly, causing the picture to appear flipped or sideways. Upside down photo To fix this is ...

Main.js in Electron cannot find the NODE_ENV environment variable

Currently, I am in the process of developing an application which involves: React 16.4.0 Electron 2.0.2 Webpack 4.11.0 After successfully compiling and running the app using webpack (webpack dev server), my focus now shifts to showing only Chr ...

Float a div within text to be positioned vertically

Is there a way to use only CSS to create an article that includes a featured quote section starting around 50px from the top? The section should be half the width of the page with text wrapping around it at the top and bottom. Currently, I am using the fl ...

Concealing and wrapping text using CSS in a table structure

My table is displayed below: <table style="width: 100%; white-space: nowrap; overflow: hidden;"> <tbody><tr> <th> Department </th> <th> Function </th> ...

Expand the width and include a placeholder in mat input field for Angular version 5

Currently utilizing a mat input with the code provided, presenting a similar appearance to the screenshot below. I am looking to add a placeholder that disappears once the user begins typing. However, in my current setup, the text shifts upward and floats ...

Encountering an npm issue following the execution of "npm run build": npm ERROR! code ELIFECYCLE npm ERROR! exit code 2

I'm struggling to troubleshoot an npm error I encountered after running my npm build script. The error output in the terminal looks like this: npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! [email protected] build: `webpack --mode production` np ...

Running my Angular Single Page Application on a self-hosted ServiceStack service

Currently, I am utilizing ServiceStack to construct a small self-hosted RESTApi service with a NoSQL database and the setup is working perfectly fine (without using .Net Core). My next step involves creating some maintenance screens using Angular. Howeve ...

Focusing on styling specifically for Chrome rather than Safari using SCSS

Is there a method to specifically target only Chrome browsers within a mixin in SCSS? @mixin { &:after { border-bottom:black; @media screen and (-webkit-min-device-pixel-ratio:0) { border-bottom: red; } } } Currently, this code targets bot ...

Ensure that the height of the flex body is set to 100% within the ReactNative View

Within my React Native app, I have constructed the following view: <ScrollView style={{ width: 250, height: '100%', backgroundColor: '#000000' }}> <SafeAreaView style={{ flex: 1, flexW ...

When the button with an image is clicked, it will display a loading element

I have developed an application that heavily utilizes ajax, and I am looking to implement the following functionality: I would like to have a button with both text and an image. When this button is clicked, it should be disabled, and instead of the origina ...

Utilizing Typescript: Ensuring an array includes only specified values from an enum through strict enforcement

In my Angular application, I have an HTTP service that returns the allowed accesses for a specific user. The response structure is as shown below:- { "accessId": 4209318492034, "folderPath": "data/sample_folder/", ...

Creating a dynamic popup/modal in Angular 7 using a service

As a newcomer to Angular, I find myself with a question regarding services. In the past, when working with other languages, I would create self-contained components that could be called from anywhere within the application. Currently, my need for popup di ...

Using TypeScript to implement Angular Draggable functionality within an ng-template

Sorry if this question has been asked before, but I couldn't find any information. I am trying to create a Bootstrap Modal popup with a form inside and I want it to be draggable. I have tried using a simple button to display an ng-template on click, b ...

Encountering an issue with Angular 12 where a TypeError is being thrown, specifically stating "Cannot read properties of null (reading 'length') at

I encountered an error message while making a http request in my Angular Service. Strangely, this error only occurs after I logout, but it disappears upon logging back in: Below is the code snippet of my authentication Service: import { Injectable } from ...

Employ CSS Grid to properly position the crimson section within the confines of the scarlet border on Level 77 of Grid Attack

I spent hours struggling with level 77 of Coding Fantasy: Grid Attack. No matter what I tried, nothing seemed to work. There are no solutions provided in the game, and there's no way to skip the level. Can anyone help me with the solution please? ...

Data extracted from the range selector

Is there a way to take values and use them for hiding or displaying certain divs? I have been using jQuery Simple Slider for this purpose. I attempted the following code, but it did not work well. I want the div with id "3" to be visible when the slider ...

Creating a dynamic and adaptive horizontal SVG line for your website

Understanding how SVGs function is still a bit unclear to me. I know that the viewBox property plays a role in scaling SVGs, and I have come across advice suggesting not to specify height and width attributes when creating responsive SVGs. While there are ...

Arranging JSON elements according to a separate array in Angular 2 or Node.js

Looking for a solution with optimal performance, I am seeking to achieve the rearrangement of a list using either Angular2 or NodeJS. My input consists of user fruit preferences' IDs {15, 43, 55, 67, 98}; In addition, I have a JSON object containin ...

How to disable scrolling for React components with CSS styling

When incorporating a React component into my HTML, I follow this pattern: <html> <body> <div id=app>${appHtml}</div> <script src="/bundle.js"></script> </body> </html> Within my application, th ...

Energetic flair for Vue animations

I am currently developing a VueJS sidebar component. The objective is to allow the parent to define a width and display a toggle button that smoothly slides the sidebar in and out. Here is an example: <template> <div class="sidebarContainer ...