Repository: pinglinh/simple_webpack_boilerplate Branch: master Commit: 0e74bdc2b53f Files: 7 Total size: 4.5 KB Directory structure: gitextract_xwhs7m5d/ ├── .babelrc ├── .gitignore ├── README.md ├── package.json ├── src/ │ ├── index.html │ └── index.js └── webpack.config.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .babelrc ================================================ { "presets": ["env", "react"] } ================================================ FILE: .gitignore ================================================ /node_modules/ /dist ================================================ FILE: README.md ================================================ # Simple webpack boilerplate A ready to use simple webpack boilerplate. ## Instructions 1. Clone this repo 2. Run `npm install` 3. Run `npm start`, **localhost:8080** will open up in your default browser **If you prefer to install things yourself you can follow the instructions below** 1. Run `npm init` and type your answers to the questions or you can run `npm init -y` to say yes to every question - you will get default settings 2. Install the following dependencies: ``` npm i react react-dom -S ``` 3. Install the following dev dependencies: ``` npm i babel-core babel-loader babel-preset-env babel-preset-react css-loader html-webpack-plugin style-loader webpack webpack-cli webpack-dev-server -D ``` 4. Update your scripts to the following: ``` "start": "webpack-dev-server --mode development --open", "build": "webpack --mode production" ``` 5. Create **.babelrc** file with the following configurations: ``` { "presets": ["env", "react"] } ``` 5. Create **webpack.config.js** file with the following configurations: ``` const HtmlWebPackPlugin = require("html-webpack-plugin"); const htmlWebpackPlugin = new HtmlWebPackPlugin({ template: "./src/index.html", filename: "./index.html" }); module.exports = { module: { rules: [ { test: /\.js$/, exclude: /node_modules/, use: { loader: "babel-loader" } }, { test: /\.css$/, use: [ { loader: "style-loader" }, { loader: "css-loader", options: { modules: true, importLoaders: 1, localIdentName: "[name]_[local]_[hash:base64]", sourceMap: true, minimize: true } } ] } ] }, plugins: [htmlWebpackPlugin] }; ``` 7. Create **src** folder with **index.js** and **index.html** file. 8. **index.js** should have: ``` import React from "react"; import ReactDOM from "react-dom"; const Index = () => { return