- First of all you need to clone project reposotory by running
git clone git clone https://github.com/atlp-rwanda/c4-barefoot-frontend.git
- run
npm init --yeshere package.json will be created imadiately
Here we need to install all packgages that will be used to set up our project
npm install reactnpm i react-domnpm i react-roouter-dom
We need compile our javascript file from ECMA2015 (ES6) to ES5
@babel/core@babel/preset-env@babel/preset-reactbabel-loaderbabel/core
npm i html-webpack-pluginnpm i htm-loader
npm i css-loadernpm i style-loader
After that we will need to run our project in devlopment we have to make sure that webpack dependencies are installed like:
npm i webpack-cliNote: here you have to pay more attation on version of webpack-cli I am using version:3.3.12other version is not workingnpm i webpacknpm i webpack-dev-serverThis will helps us to run server automatically after save when you change any file content
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin')
process.env.NODE_ENV = 'development';
module.exports = {
mode: 'development',
devtool: 'cheap-module-source-map',
entry: './src/index.js',
output: {
path: path.resolve(__dirname, "build"),
publicPath: '/',
filename: 'bundle.js'
},
devServer: {
stats:'minimal',
overlay: true,
historyApiFallback: true,
disableHostCheck: true,
headers: { "Access-Control-Allow-Origin": "*"},
https: false
},
plugins: [
new HtmlWebpackPlugin({
template: "public/index.html"
})
],
module : {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ["babel-loader"]
},
{
test: /(\.css)$/,
use: ["style-loader", "css-loader"]
},
{
test: /\.html$/,
use: [
{
loader: "html-loader"
}
]
}
]
}
};
you will get error that says no start script available now you can guess what do right now
let jump into package.json and configure start script
"start": "webpack-dev-server --config webpack.config.js --port 3000 --open"
}
so far you can run npm start