官术网_书友最值得收藏!

There's more...

You're probably curious about how the CSS code is added to the browser since we haven't imported a CSS file to our project directly (by using a <link> tag, for example). Well, you will be surprised to see that the CSS code is being injected into our <head> tag using the <style> tag for each imported stylesheet. If you inspect your project with Chrome DevTools you will see something like this:

This behavior is because the style-loader is a Webpack loader that is being used by default in our application when we create it with create-react-app:

There is no way to modify the Webpack configuration directly when we use create-react-app because it is using a package called react-scripts, but in Chapter 10, Mastering Webpack, we will see how to configure our Webpack without using a starting kit such as create-react-app.

There are more Webpack loaders that do different things, such as css-loader for CSS modules, sass-loader to implement Sass, stylus-loader to implement Stylus, and extract-text-plugin to move the CSS code to a .css file instead of injecting it to the DOM (usually, this is only used in production).

主站蜘蛛池模板: 湄潭县| 东平县| 修文县| 宾川县| 仙居县| 洛隆县| 尚义县| 安丘市| 洛南县| 崇仁县| 和田县| 会理县| 岳池县| 高州市| 德庆县| 噶尔县| 崇左市| 田林县| 台湾省| 晋中市| 高阳县| 阳东县| 柳河县| 泸定县| 桃园县| 南丹县| 玉门市| 连云港市| 甘肃省| 伽师县| 秦皇岛市| 靖远县| 浠水县| 安乡县| 绵阳市| 文安县| 怀集县| 望江县| 台南市| 永昌县| 沂源县|