It's a way to have more than a single APP/Views into the same React Project (With CRA or not)
https://github.com/facebook/create-react-app/issues/1084#issuecomment-308731651
(say we add an admin.html):
npm run eject
const entries = {
'main' : [
require.resolve('react-dev-utils/webpackHotDevClient'),
paths.appIndexJs,
],
'admin': [paths.adminIndexJs],
};
add a new plugin node:
new HtmlWebpackPlugin(
Object.assign(
{},
{
chunks: ["admin"],
inject: true,
template: paths.appHtml,
// filename: '../tmp/admin.html',
},
isEnvProduction
? {
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true,
},
}
: undefined
)
),
OR
new HtmlWebpackPlugin({
inject: true,
chunks: ["index"],
template: paths.appHtml,
}),
new HtmlWebpackPlugin({
inject: true,
chunks: ["admin"],
template: paths.appHtml,
filename: 'admin.html',
}),
rewrite urls/config/webpackDevServer.config.js:
historyApiFallback: {
disableDotRule: true,
rewrites: [
{ from: /^\\/admin.html/, to: '/build/admin.html' },
]
}