diff --git a/.vscode/settings.json b/.vscode/settings.json index a5f9e023..cbd787ce 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -53,5 +53,8 @@ "webrowse" ], "reactSnippets.settings.prettierEnabled": true, - "reactSnippets.settings.importReactOnTop": false + "reactSnippets.settings.importReactOnTop": false, + "[html]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + } } diff --git a/config/paths.js b/config/paths.js index 3d008e9f..bf0ae7c6 100644 --- a/config/paths.js +++ b/config/paths.js @@ -58,6 +58,8 @@ module.exports = { appPublic: resolveApp("public"), appHtml: resolveApp("public/index.html"), appIndexJs: resolveModule(resolveApp, "src/index"), + embedAppHtml: resolveApp("public/embed.html"), + embedAppIndexJs: resolveModule(resolveApp, "src/embed"), appPackageJson: resolveApp("package.json"), appSrc: resolveApp("src"), appTsConfig: resolveApp("tsconfig.json"), diff --git a/config/webpack.config.js b/config/webpack.config.js index b2fc1ad1..c06061c6 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -118,7 +118,7 @@ module.exports = function (webpackEnv) { : isEnvDevelopment && "cheap-module-source-map", // These are the "entry points" to our application. // This means they will be the "root" imports that are included in JS bundle. - entry: paths.appIndexJs, + entry: { main: paths.appIndexJs, embed: paths.embedAppIndexJs }, output: { // The build folder. path: paths.appBuild, @@ -128,7 +128,7 @@ module.exports = function (webpackEnv) { // In development, it does not produce real files. filename: isEnvProduction ? "static/js/[name].[contenthash:8].js" - : isEnvDevelopment && "static/js/bundle.js", + : isEnvDevelopment && "static/js/[name].bundle.js", // There are also additional JS chunk files if you use code splitting. chunkFilename: isEnvProduction ? "static/js/[name].[contenthash:8].chunk.js" @@ -260,18 +260,6 @@ module.exports = function (webpackEnv) { // match the requirements. When no loader matches it will fall // back to the "file" loader at the end of the loader list. oneOf: [ - // TODO: Merge this config once `image/avif` is in the mime-db - // https://github.com/jshttp/mime-db - { - test: [/\.avif$/], - type: "asset", - mimetype: "image/avif", - parser: { - dataUrlCondition: { - maxSize: imageInlineSizeLimit - } - } - }, // "url" loader works like "file" loader except that it embeds assets // smaller than specified limit in bytes as data URLs to avoid requests. // A missing `test` is equivalent to a match. @@ -409,8 +397,37 @@ module.exports = function (webpackEnv) { Object.assign( {}, { + filename: "index.html", inject: true, - template: paths.appHtml + template: paths.appHtml, + chunks: ["main"] + }, + isEnvProduction + ? { + minify: { + removeComments: true, + collapseWhitespace: true, + removeRedundantAttributes: true, + useShortDoctype: true, + removeEmptyAttributes: true, + removeStyleLinkTypeAttributes: true, + keepClosingSlash: true, + minifyJS: true, + minifyCSS: true, + minifyURLs: true + } + } + : undefined + ) + ), + new HtmlWebpackPlugin( + Object.assign( + {}, + { + filename: "embed.html", + inject: true, + template: paths.embedAppHtml, + chunks: ["embed"] }, isEnvProduction ? { diff --git a/public/embed.html b/public/embed.html new file mode 100644 index 00000000..cac3ab27 --- /dev/null +++ b/public/embed.html @@ -0,0 +1,116 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + +