From the course: SharePoint Framework for Developers: 1 Understanding the Toolchain

Unlock the full course today

Join today to access over 22,700 courses taught by industry experts or purchase this course individually.

Use webpack to bundle CSS

Use webpack to bundle CSS

From the course: SharePoint Framework for Developers: 1 Understanding the Toolchain

Start my 1-month free trial

Use webpack to bundle CSS

- [Instructor] Now so far we have seen an example of Webpack allowing us to bundle a JavaScript file. A JavaScript file that has dependencies on other JavaScript files and be able to run it as a single bundle.js. Webpack can be used to bundle other kinds of files as well. So next let's look at how Webpack helps us bundle CSS files. So I'm going to go ahead and introduce a new file here called style.css. And inside here I will place a simple style. Now what I wish to be able to do is that this hello style that we have introduced, I would like this hello style to be used in the new element that we are creating here. So let's make a minor code change here to sort of verify that indeed the style does get used. So the code change I need to make here is actually very simple. I simply say element.classlist.add hello. The end result of this will be that the element that we are adding will now have a class, a css class associated with it called hello. And that is the class that we have…

Contents