There's more...

Let's implement CSS preprocessors such as Sass, Stylus, and LessCSS:

  1. If you want to extract your CSS code to a style.css file and compress the code for production mode, you can use the extract-text-webpack-plugin package:
   npm install extract-text-webpack-plugin@v4.0.0-beta.0
  1. We need to add this to our Webpack plugins:
  import HtmlWebPackPlugin from 'html-webpack-plugin';  import ExtractTextPlugin from 'extract-text-webpack-plugin';  const isProduction = process.env.NODE_ENV === 'production';  const plugins = [    new HtmlWebPackPlugin({      title: 'Codejobs',      template: './src/index.html',      filename: './index.html'    })  ];  if (isProduction) {    plugins.push(      new ExtractTextPlugin({        allChunks: true,        filename: './css/[name].css'      }) ); ...

Get React Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.