npm i @tenjojeremy/webpack-config
Create .webpack.manifest.js
to root
Create .babelrc.js
to root with:
module.exports = { extends: './node_modules/@tenjojeremy/webpack-config/.babelrc' }
Add to Package.json
"scripts": {
"start": "npx webpack-scripts start",
"build": "npx webpack-scripts build",
"build:analyze": "npm run build && npx webpack-scripts analyze",
},
Start development
npm run start
Create Build
npm run build
Analyze Build
npm run analyze
Install:
npm i react-hot-loader
Add to index component, replace IndexComp
as nessesary:
import { hot } from 'react-hot-loader/root'
const IndexComp = () => {}
export default hot(IndexComp)
Reference: https://github.com/gaearon/react-hot-loader
const localIp = require('get-my-local-ip')
exports.manifest = {
projectInfo: {
name: 'Webpack Config',
shortName: 'Webpack',
description: 'Webpack Config',
colors: {
primary: '#6200ee',
background: '#6200ee',
},
logo: {
path: 'tests/logo.png',
},
},
webpack: {
devServer: {
port: 3001,
host: localIp.address,
},
entry: './tests/entry.js',
plugins: {
html: {
bodyHtmlSnippet: '',
},
},
},
}
if logo-maskable
exists it will add a 142px
maskable icon to manifest
The bin
option in the package.json
file has a file named webpack-scripts
and you call it in the installed app by using yarn webpack-scripts start/build
- Brotli
- Minify
- Remove comment
- Remove new lines
- Remove whitespaces
- Code split pages
- minify bundle
- Add js tag to head with defer attribute
- preload css
- add critical css to header
- Convert images to Webp
- use WOFF2 format
- preload fonts
- download font to use locally