

Or together with peer dependencies: npm install pug pug-loader html-webpack-plugin html-webpack-template-pug -save-dev Install the template with npm: npm install html-webpack-template-pug -save-dev Loading the template requires that pug-loader and consequently pug be available in node_modules.

In addition to the options that should cover most needs of a single-page app, a custom Pug file can be used to extend the provided layout.pug or to completely rewrite the template while utilizing mixins from mixins.pug. Inspired by another template, html-webpack-template. ( is a Pug template for the webpack plugin html-webpack-plugin. Now, below is the complete Webpack configuration. This will open the browser automatically and launch your application in ( Docs) We set historyApiFallback to true and open to true. We specify localhost as the host and assign the variable port as the port (if you remember, we assigned port 3000 to this variable). Later we will be adding other plugins for Bundle Analyzer and HMR.įinally, we configure the development server. In our case we specify the HTML template we will be using and the favicon. Html-webpack-plugin accepts an object with different options. This section is where we configure (as the name implies) plugins. If you inspect it you will see the bare bones configuration: from './styles.css' This first command will create our directory and move into it, then we initialize a package.json accepting defaults. In your terminal type the following: mkdir webpack-for-react & cd $_ Let us start by creating our directory and package.json. Note: You can use npm if you wish, although the commands will vary slightly. In this tutorial we will see the basics of Webpack for React to get you started, including React Router, Hot Module Replacement (HMR), Code Splitting by Route and Vendor, production configuration and more.īefore we start, here’s the full list of features we are going to set up together in this tutorial:Īnd you should have at least some basic knowledge of React and React Router.
