![how to run webpack for dev how to run webpack for dev](https://blog.nativescript.org/images/gchvacwikmh3t7j2vevf.png)
In the root of the project I will create a file named .įirst I’m going to add some helpful variables and functions.Ĭonst HtmlWebpackPlugin = require('html-webpack-plugin') Ĭonst appDirectory = fs.realpathSync(process.cwd()) The next step is to work on the webpack config file.
How to run webpack for dev install#
Go ahead and run npm install to install these dependencies. Npm start will run the command client webpack-dev-server and tell it to look for the Webpack config. When you’re going to run npm start on your terminal.
How to run webpack for dev code#
The next important part of this code is the script that was added. webpack-dev-server – Will enable use to create a localhost dev environment.webpack-cli – Allows us to use the webpack command client tool.webpack – Will allow us to bundle all of our code into a final build.react-dom – Will allow us to grab a React app and dump onto to the DOM.react – Will allow us to write React code.$ npm i -save-dev html-webpack-plugin webpack webpack-cli webpack-dev-server "įor the moment I’m going to install the minimal dependencies to get a React dev server running. That script tag will be the entry point to the React application. Later in this guide, I will tell Webpack to use this HTML file for development and to automatically inject a script tag element at the bottom of this file.
![how to run webpack for dev how to run webpack for dev](https://i.stack.imgur.com/PXdWH.png)
This HTML has 1 simple job, and that is to serve our React app and attach it to a div element with an ID of root. Inside the public directory, I will add a file called, index.html. The public directory is responsible for holding any CSS stylesheets, image assets, and of course, your skeleton HTML markup. The first step I will take is to create a directory called, public.