Let's implement CSS preprocessors such as Sass, Stylus, and LessCSS:
- 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
- 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' }) ); ...