Bit of Background story:
I am preparing for interviews where I have to create lots of mini projects and always needs the setup of webpack, node and es6.
So I wrote a batch script which does that for me and thought it will be helpful for you
Follow the instruction to create a set up
-
Clone the repo or download it
-
Open command prompt and cd into the folder and run batch file
i.e cd createWebpack
Node_Webpack.bat
-
It will ask for the name of the project that you want to create
e.g carrots
-
Simply press enter or filled the project detail
e.g package name: (carrots) version: (1.0.0)
description:
entry point: (index.js)
test command:
git repository:
keywords:
author:
license: (ISC) -
It will display the package.json on the terminal
-
It will atuomatically start installing the webpack
-
Once it is done it will show following lines of instruction to follow
"Your Project is created please copy/past the below lines inside package.json under 'scripts'"
"start": "npm run webpack", "webpack": "webpack -d --watch",
-
After following above instruction your pacakge.json will look like this
{ "name": "<ProjectName>", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "start": "npm run webpack", "webpack": "webpack -d --watch", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "devDependencies": { "webpack": "^4.35.0", "webpack-cli": "^3.3.5" } }
-
You are done completely!!!
-
You can create the index.html in the root folder and include the bundle.js from ./dist/bundle.js inside script tag
-
Your project structure will look something like this
.
├── index.html
├── package.json
├── webpack.config.js
├── ...
├── src
│ ├── app.js
├── ...
├── dist
│ ├── bundle.js