How to use webpack with antd - reactjs

I try to customize a theme of antd with webpack.config.js, but I don't understand how it works. I want to customize the CSS with less-loader.
I follow this link
I have a `webpack.config.js :
module.exports = {
rules: [{
test: /\.less$/,
use: [{
loader: 'style-loader',
}, {
loader: 'css-loader', // translates CSS into CommonJS
}, {
loader: 'less-loader', // compiles Less to CSS
options: {
lessOptions: { // If you are using less-loader#5 please spread the lessOptions to options directly
modifyVars: {
'font-size-base': '140px'
},
javascriptEnabled: true,
},
},
}],
}],
}
But the font size base doesn't change anyway.
Note: I develop a React application with TypeScript.

npm install craco-less --save
in my package.json (for craco less add this):
{
"dependencies": {
"#craco/craco": "^5.6.4",
"craco-less": "^1.17.0"
},
"scripts": {
"start": "craco start",
"build": "craco build",
"test": "craco test",
"eject": "craco eject"
},
"devDependencies": {
"less": "^4.0.0",
"less-loader": "^7.2.1"
}
}
At the root of the project i had a craco.config.js :
const CracoLessPlugin = require('craco-less');
module.exports = {
plugins: [
{
plugin: CracoLessPlugin,
options: {
lessLoaderOptions: {
lessOptions: {
modifyVars: { '#primary-color': 'rgba(0, 0, 0, 0.87);' },
javascriptEnabled: true,
},
},
},
},
],
};
If you want to modify the theme indicate the modification in modifyVars
Vars of antd : https://ant.design/docs/react/customize-theme#Ant-Design-Less-variables
And in my react component i had :
import './competenceGrid.less';
The competenceGrid.less :
#import '~antd/dist/antd.less';
/*some css*/
}

Related

React useWindowSize hook no longer works in project without CRA

This simple hook is supposed to return the window width and height. I made this hook in a project where I used CRA where I faced no issues. In the current project, i have not used CRA in order to get a better understanding of how react works. Therefore, I think the error I receive might have to do with my webpack configs or dependencies.
Uncaught TypeError: can't access property "type", currentEvent is null
import { useState, useEffect } from "react";
export default function useWindowSize() {
const [windowSize, setWindowSize] = useState({
width: undefined,
height: undefined,
});
useEffect(() => {
const handleResize = () =>
setWindowSize({ width: window.innerWidth, height: window.innerHeight });
window.addEventListener("resize", handleResize);
handleResize();
return () => window.removeEventListener("resize", handleResize);
}, []);
return windowSize;
}
WEBPACK.CONFIG.JS
const path = require("path");
const HTMLWebpackPlugin = require("html-webpack-plugin");
module.exports = {
entry: "./src/index.jsx",
output: {
path: path.join(__dirname, "/dist"),
filename: "bundle.js",
},
plugins: [
new HTMLWebpackPlugin({
template: "./public/index.html",
}),
],
module: {
rules: [
{
test: /\.jsx|js$/,
include: path.resolve(__dirname, "src"),
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: [
[
"#babel/preset-env",
{
targets: "defaults",
},
],
"#babel/preset-react",
],
},
},
},
{
test: /\.(jpe?g|png|ico|svg|gif)$/i,
use: {
loader: "file-loader",
options: { name: "[name].[ext]" },
},
},
{ test: /\.css$/, use: ["style-loader", "css-loader"] },
],
},
};
PACKAGE.JSON
{
"name": "cra",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server --mode development --open --hot",
"build": "webpack --mode production"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"css-loader": "^6.7.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"style-loader": "^3.3.1"
},
"devDependencies": {
"#babel/core": "^7.20.2",
"#babel/preset-env": "^7.20.2",
"#babel/preset-react": "^7.18.6",
"babel-loader": "^9.1.0",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.5.0",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.11.1"
}
}
EDIT : I should mention that I receive the window size at the initial render, the error happens when I actually try to resize the window
I tried many things to understand this issue however I am still unsuccesful in solving it. Any assistance would be appreciated.
For anyone facing a similar problem, you need this dependency for useState()
npm install react-refresh -D

How to enable import assertions for Babel?

In my React app I want to use import assertion:
import data from "./json/clients-m.json" assert { type: "json" }
However, I get the following error:
ERROR in ./src/Clients.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: E:\src\Clients.js: Support for the experimental syntax 'importAssertions' isn't currently enabled.
Add #babel/plugin-syntax-import-assertions (https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-import-assertions) to the 'plugins' section of your Babel config to enable parsing.
Line 1:41: Parsing error: This experimental syntax requires enabling the parser plugin: "importAssertions". (1:41)
I have installed this plugin:
npm install #babel/plugin-syntax-import-assertions --save-dev
Then I created .babelrc.json:
{
"plugins": [
"#babel/plugin-syntax-import-assertions"
]
}
And also added this plugin into package.json:
{
"name": "clients-frontend",
"version": "0.1.0",
"private": true,
"babel": {
"plugins": [
"#babel/plugin-syntax-import-assertions"
]
},
"dependencies": {
"#testing-library/jest-dom": "^5.16.4",
"#testing-library/react": "^13.1.1",
"#testing-library/user-event": "^13.5.0",
"bootstrap": "^5.1.3",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"devDependencies": {
"#babel/plugin-syntax-import-assertions": "^7.16.7"
}
}
However, I keep getting this error. 😐
react-scripts doesn't load babel configuration by default. Install the following packages
npm i -D customize-cra react-app-rewired
These packages let you customize react-scripts's default configuration for babel so you can use additional plugins
Now, change the scripts in your package.json
"scripts": {
- "start": "react-scripts start",
+ "start": "react-app-rewired start",
- "build": "react-scripts build",
+ "build": "react-app-rewired build",
- "test": "react-scripts test",
+ "test": "react-app-rewired test"
}
Create a file config-overrides.js at the root of your app with the following content
/* config-overrides.js */
/* eslint-disable react-hooks/rules-of-hooks */
const { useBabelRc, override } = require('customize-cra');
module.exports = override(useBabelRc());
Now, create .babelrc at the root of your package
{
"plugins": [
"#babel/plugin-syntax-import-assertions"
]
}
Now, your babel configuration will be loaded correctly. There's another library craco that lets you customize the react-scripts configuration
Try installing the babel-eslint package as well. And, in your .eslintrc.json file add:
{
"parserOptions": {
"babelOptions": {
"parserOpts": {
"plugins": ["importAssertions"]
}
}
}
}
npm install #babel/plugin-syntax-import-assertions --save-dev
babel.config.cjs
module.exports = function (api) {
api.cache(true);
let presets = [];
let plugins = [];
switch (process.env['NODE_ENV']) {
case 'test':
presets = [
[
'#babel/preset-env',
{
targets: {
node: 'current',
},
},
],
];
plugins = [
'babel-plugin-transform-import-meta',
'#babel/plugin-proposal-export-default-from',
'#babel/plugin-syntax-import-assertions'
];
break;
default:
presets = [
[
'#babel/preset-env',
{
modules: false, //Setting this to false will preserve ES services
targets: {
node: 'current',
},
},
],
];
plugins = ['#babel/plugin-syntax-import-assertions'];
break;
}
return {
presets,
plugins,
};
};
If you (like me) use an ejected react-script app, maybe you need to set your configuration in webpack.config.js in the application-scope babel-loader:
// Process application JS with Babel.
// The preset includes JSX, Flow, TypeScript, and some ESnext features.
{
test: /\.(js|mjs|jsx|ts|tsx)$/,
include: paths.appSrc,
loader: require.resolve('babel-loader'),
options: {
customize: require.resolve('babel-preset-react-app/webpack-overrides',),
presets: [/* ... */],
plugins: [ // ADD THIS 👇
require.resolve('#babel/plugin-syntax-import-assertions'),
[require.resolve('babel-plugin-direct-import'), {
modules: [
require.resolve('#mui/material'),
require.resolve('#mui/icons-material'),
require.resolve('#mui/lab'),
require.resolve('#mui/base'),
require.resolve('#mui/system'),
],
}],
isEnvDevelopment && shouldUseReactRefresh && require.resolve('react-refresh/babel'),
].filter(Boolean),
// ...
},
},
But NOT here:
// Process any JS outside of the app with Babel.
// Unlike the application JS, we only compile the standard ES features.
{
test: /\.(js|mjs)$/,
exclude: /#babel(?:\/|\\{1,2})runtime/,
// ...

How to compile React JS code using Craco?

I created a React JS app using the npm create-react-app command.
In this project, I wanted to use Tailwind CSS so I installed and used Craco as showed in the Tailwind Setup Documentation.
But since then my js code doesn't compile at all.
I would like to know how to fix this problem and associate a compiler to Craco for my js code such as babel.
Here are my scripts set in package.json:
"scripts": {
"start": "craco start",
"build": "craco build",
"test": "craco test",
"eject": "react-scripts eject"
},
This is my craco.config.js file:
module.exports = {
style: {
postcss: {
plugins: [
require('tailwindcss'),
require('autoprefixer'),
],
},
},
}
Try with this
module.exports = {
style: {
postcss: {
plugins: [require('tailwindcss'), require('autoprefixer')],
},
},
webpack: {
configure: {
module: {
rules: [
{
type: 'javascript/auto',
test: /\.woff2$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/',
},
},
],
},
],
},
},
},
};

electron-builder built app doesn't run after build, but works before

I have a project which uses both electron-packager and electron-builder. When I run npm run packaged it is packaged up as .app file into the builds/ folder and there is no issue running the app. When I run npm run build or npm run build:mac, electron-builder successfully builds, signs and creates a .dmg and a .zip file as well as the .app file into the dist/ folder, however the .app file doesn't run as it appears that the src has not compiled correctly and files are missing. I'm sure I'm over looking something in my config but have hit a roadblock.
Here is my package.json:
{
"name": "my-electron-app",
"productName": "ACME Electron",
"version": "0.1.0",
"license": "MIT",
"main": "mainprocess/main.js",
"scripts": {
"start": "react-scripts start",
"clean:build": "rimraf builds",
"clean:dist": "rimraf dist",
"tes": "rimraf archive/tunnel-utils-darwin-x64",
"testDev": "cross-env NODE_ENV=development electron .",
"testProd": "cross-env NODE_ENV=production electron . --noDevServer",
"dev": "webpack-dev-server --progress --hot --host 0.0.0.0 --config=./webpack.dev.config.js",
"build": "npm run clean:dist && webpack --progress --config webpack.build.config.js",
"package": "cross-env NODE_ENV=production npm run clean:dist && webpack --config webpack.build.config.js",
"postpackage": "cross-env NODE_ENV=production npm run clean:build && electron-packager . ${npm_package_productName} --overwrite --icon=assets/icons/mac/icon.icns --prune=true --ignore='(.circleci|archive|assets|build|builds|signing|scaffold|src)' --asar.unpackDir=node_modules/ngrok/* --out=builds",
"package-mac": "cross-env NODE_ENV=production electron-packager . ${npm_package_productName} --overwrite --platform=darwin --arch=x64 --icon=assets/icons/mac/icon.icns --prune=true --ignore='(.circleci|archive|assets|build|builds|signing|scaffold|src)' --asar.unpackDir=node_modules/ngrok/* --out=builds",
"package-win": "cross-env NODE_ENV=production electron-packager . ${npm_package_productName} --overwrite --platform=win32 --arch=ia32 --icon=assets/icons/win/icon.ico --prune=true --asar.unpackDir=node_modules/ngrok/* --out=builds --version-string.CompanyName=ACME --version-string.FileDescription=ACME --version-string.ProductName=\"My App\"",
"package-linux": "cross-env NODE_ENV=production electron-packager . ${npm_package_productName} --overwrite --platform=linux --arch=x64 --icon=assets/icons/png/icon.png --prune=true --ignore='(scaffold|src|builds|archive)' --asar.unpackDir=node_modules/ngrok/* --out=builds",
"pack": "electron-builder --dir",
"dist": "electron-builder",
"build-bak": "run-os",
"build:win32": "electron-builder --win",
"build:darwin": "electron-builder --mac",
"clean": "rimraf ./dist",
"release": "electron-builder --publish always",
"postinstall": "electron-builder install-app-deps"
},
"build": {
"appId": "com.acme.app",
"productName": "ACME Electron",
"files": [
"**/*",
"builds/Release/*",
"assets/icons/*.*",
"assets/icons/mac/*.*",
"assets/icons/png/*.*",
"assets/icons/win/*.*"
],
"mac": {
"category": "public.build.automation",
"icon": "assets/icons/mac/icon.icns"
},
"dmg": {
"contents": [
{
"x": 110,
"y": 150
},
{
"x": 440,
"y": 150,
"type": "link",
"path": "/Applications"
}
],
"artifactName": "acme-app-${version}.${ext}"
},
"win": {
"target": [
{
"target": "nsis",
"arch": [
"x64"
]
},
{
"target": "portable"
}
],
"icon": "assets/icons/win/icon.ico"
},
"nsis": {
"runAfterFinish": true,
"installerIcon": "assets/icons/win/icon.ico",
"artifactName": "acme-app-${version}.${ext}"
},
"portable": {
"artifactName": "acme-app.exe"
},
"appx": {
"applicationId": "acme.app",
"backgroundColor": "#000000",
"identityName": "acme.app",
"publisherDisplayName": "nolandubeau",
"artifactName": "acme-app-${version}.${ext}"
},
"publish": [
{
"provider": "github",
"releaseType": "release"
}
]
},
"dependencies": {
...
},
"devDependencies": {
...
}
}
And here is my webpack.build.config.js:
const webpack = require('webpack');
const path = require('path');
//const BabiliPlugin = require('babili-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
// Config directories
const SRC_DIR = path.resolve(__dirname, 'src');
const OUTPUT_DIR = path.resolve(__dirname, 'dist');
// Any directories you will be adding code/files into, need to be added to this array so webpack will pick them up
const defaultInclude = [ SRC_DIR ];
module.exports = {
entry: SRC_DIR + '/index.js',
output: {
path: OUTPUT_DIR,
publicPath: './',
filename: 'bundle.js'
},
module: {
rules: [
{ test: /\.css$/, use: ['style-loader', 'css-loader'] },
{ test: /\.json$/, loader: "json-loader" },
{
test: /\.less$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{ loader: 'css-loader' },
{ loader: 'less-loader' }
]
}),
include: defaultInclude
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['#babel/preset-env', '#babel/react'],
plugins: ['#babel/proposal-class-properties', '#babel/plugin-proposal-object-rest-spread', '#babel/plugin-syntax-dynamic-import']
}
}
},
{
test: /\.(jpe?g|png|gif)$/,
use: [
{ loader: 'file-loader?name=img/[name]__[hash:base64:5].[ext]' }
],
include: defaultInclude
},
{
test: /\.(eot|svg|ttf|woff|woff2)$/, use: [
{ loader: 'file-loader?name=font/[name]__[hash:base64:5].[ext]' }
],
include: defaultInclude
}
]
},
target: 'electron-renderer',
plugins: [
new HtmlWebpackPlugin({title: 'CaptureCloud Remote'}),
new ExtractTextPlugin("bundle.css"),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new webpack.LoaderOptionsPlugin({
debug: false,
optimization: {
minimizer: [
new UglifyJsPlugin({
sourceMap: true,
}),
],
}
})
//new BabiliPlugin()
],
stats: {
colors: true,
children: false,
chunks: false,
modules: false
}
};

framework7-cli generated app dev server doesn't update

I used the new Framework7-cli to generate a Cordova App with React presets. When everything was finished setting up I ran npm run start and tried changing some code in /pages/home.jsx, but nothing was updated in the browser. Does anyone know why this doesn't work right out of the box?
Here is what webpack.config.js looks like:
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const WorkboxPlugin = require('workbox-webpack-plugin');
const path = require('path');
function resolvePath(dir) {
return path.join(__dirname, '..', dir);
}
const env = process.env.NODE_ENV || 'development';
const target = process.env.TARGET || 'web';
const isCordova = target === 'cordova';
module.exports = {
mode: env,
entry: [
'./src/js/app.js',
],
output: {
path: resolvePath(isCordova ? 'cordova/www' : 'www'),
filename: 'js/app.js',
publicPath: '',
hotUpdateChunkFilename: 'hot/hot-update.js',
hotUpdateMainFilename: 'hot/hot-update.json',
},
resolve: {
extensions: ['.js', '.jsx', '.json'],
alias: {
'#': resolvePath('src'),
},
},
devtool: env === 'production' ? 'source-map' : 'eval',
devServer: {
hot: true,
open: true,
compress: true,
contentBase: '/www/',
disableHostCheck: true,
watchOptions: {
poll: 1000,
},
},
optimization: {
minimizer: [new TerserPlugin({
sourceMap: true,
})],
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
use: 'babel-loader',
include: [
resolvePath('src'),
resolvePath('node_modules/framework7'),
resolvePath('node_modules/framework7-react'),
resolvePath('node_modules/template7'),
resolvePath('node_modules/dom7'),
resolvePath('node_modules/ssr-window'),
],
},
{
test: /\.css$/,
use: [
(env === 'development' ? 'style-loader' : {
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: '../'
}
}),
'css-loader',
'postcss-loader',
],
},
{
test: /\.styl(us)?$/,
use: [
(env === 'development' ? 'style-loader' : {
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: '../'
}
}),
'css-loader',
'postcss-loader',
'stylus-loader',
],
},
{
test: /\.less$/,
use: [
(env === 'development' ? 'style-loader' : {
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: '../'
}
}),
'css-loader',
'postcss-loader',
'less-loader',
],
},
{
test: /\.(sa|sc)ss$/,
use: [
(env === 'development' ? 'style-loader' : {
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: '../'
}
}),
'css-loader',
'postcss-loader',
'sass-loader',
],
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: 'images/[name].[ext]',
},
},
{
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac|m4a)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: 'media/[name].[ext]',
},
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: 'fonts/[name].[ext]',
},
},
],
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(env),
'process.env.TARGET': JSON.stringify(target),
}),
...(env === 'production' ? [
new OptimizeCSSPlugin({
cssProcessorOptions: {
safe: true,
map: { inline: false },
},
}),
new webpack.optimize.ModuleConcatenationPlugin(),
] : [
// Development only plugins
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(),
]),
new HtmlWebpackPlugin({
filename: './index.html',
template: './src/index.html',
inject: true,
minify: env === 'production' ? {
collapseWhitespace: true,
removeComments: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
useShortDoctype: true
} : false,
}),
new MiniCssExtractPlugin({
filename: 'css/app.css',
}),
new CopyWebpackPlugin([
{
from: resolvePath('src/static'),
to: resolvePath(isCordova ? 'cordova/www/static' : 'www/static'),
},
{
from: resolvePath('src/manifest.json'),
to: resolvePath('www/manifest.json'),
},
]),
...(!isCordova ? [
new WorkboxPlugin.InjectManifest({
swSrc: resolvePath('src/service-worker.js'),
})
] : []),
],
};
And here is package.json
{
"name": "my-app",
"private": true,
"version": "1.0.0",
"description": "My App",
"repository": "",
"license": "UNLICENSED",
"framework7": {
"cwd": "/home/david/test-react",
"type": [
"pwa",
"cordova",
"web"
],
"name": "My App",
"pkg": "io.framework7.myapp",
"framework": "react",
"template": "single-view",
"cssPreProcessor": false,
"bundler": "webpack",
"cordova": {
"folder": "cordova",
"platforms": [
"ios",
"android"
],
"plugins": [
"cordova-plugin-statusbar",
"cordova-plugin-keyboard",
"cordova-plugin-splashscreen",
"cordova-plugin-wkwebview-engine"
]
},
"webpack": {
"developmentSourceMap": true,
"productionSourceMap": true,
"hashAssets": false,
"preserveAssetsPaths": false,
"inlineAssets": true
},
"theming": {
"customColor": false,
"color": "#007aff",
"darkTheme": false,
"iconFonts": true,
"fillBars": false
},
"customBuild": false
},
"scripts": {
"build-dev": "cross-env NODE_ENV=development node ./build/build.js",
"build-prod": "cross-env NODE_ENV=production node ./build/build.js",
"build-cordova-dev": "cross-env TARGET=cordova cross-env NODE_ENV=development node ./build/build.js && cd cordova && cordova build",
"build-cordova-prod": "cross-env TARGET=cordova cross-env NODE_ENV=production node ./build/build.js && cd cordova && cordova build",
"build-cordova-ios-dev": "cross-env TARGET=cordova cross-env NODE_ENV=development node ./build/build.js && cd cordova && cordova build ios",
"build-cordova-ios-prod": "cross-env TARGET=cordova cross-env NODE_ENV=production node ./build/build.js && cd cordova && cordova build ios",
"build-cordova-android-dev": "cross-env TARGET=cordova cross-env NODE_ENV=development node ./build/build.js && cd cordova && cordova build android",
"build-cordova-android-prod": "cross-env TARGET=cordova cross-env NODE_ENV=production node ./build/build.js && cd cordova && cordova build android",
"dev": "cross-env NODE_ENV=development webpack-dev-server --config ./build/webpack.config.js",
"start": "npm run dev",
"postinstall": "cpy './node_modules/framework7-icons/fonts/*.*' './src/fonts/'"
},
"browserslist": [
"Android >= 5",
"IOS >= 9.3",
"Edge >= 15",
"Safari >= 9.1",
"Chrome >= 49",
"Firefox >= 31",
"Samsung >= 5"
],
"dependencies": {
"dom7": "^2.1.3",
"framework7": "^4.5.0",
"framework7-icons": "^2.3.1",
"framework7-react": "^4.5.0",
"prop-types": "^15.7.2",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"template7": "^1.4.2"
},
"devDependencies": {
"#babel/core": "^7.5.5",
"#babel/plugin-syntax-dynamic-import": "^7.2.0",
"#babel/plugin-transform-runtime": "^7.5.5",
"#babel/preset-env": "^7.5.5",
"#babel/preset-react": "^7.0.0",
"#babel/runtime": "^7.5.5",
"babel-loader": "^8.0.6",
"chalk": "^2.4.2",
"copy-webpack-plugin": "^5.0.4",
"cpy-cli": "^2.0.0",
"cross-env": "^5.2.0",
"css-loader": "^3.2.0",
"file-loader": "^4.2.0",
"html-webpack-plugin": "^3.2.0",
"mini-css-extract-plugin": "^0.8.0",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"ora": "^3.4.0",
"postcss-loader": "^3.0.0",
"postcss-preset-env": "^6.7.0",
"rimraf": "^3.0.0",
"style-loader": "^1.0.0",
"terser-webpack-plugin": "^1.4.1",
"url-loader": "^2.1.0",
"webpack": "^4.39.2",
"webpack-cli": "^3.3.7",
"webpack-dev-server": "^3.8.0",
"workbox-webpack-plugin": "^4.3.1"
}
}
I see one little but very important problem here. In Your package.json-->scripts-->start You don't include some commands.
It should look like this:
"start": "npm run — mode development — open — hot",
What is going on here:
When You trigger npm start, webpack-dev-server is going to fire up the application in mode=development.
Then ( — open) displays it in your default browser automatically.
And finally, ( — hot) keeps watching for any changes made to the application.
If it doesn't help You try this one:
"start": "npm run — mode dev — open — hot",
Good luck :)

Resources