Skip to content

Commit

Permalink
BUGFIX/HCMPRE-1852 :: FIxed the build config file (#2169)
Browse files Browse the repository at this point in the history
* BUGFIX/HCMPRE-1852 :: FIxed the build config file

* Update webpack.config.js
  • Loading branch information
jagankumar-egov authored Jan 28, 2025
1 parent ca6bf6f commit 01350c4
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions health/micro-ui/web/console/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");

module.exports = {
// mode: "development", // Uncomment for development
entry: "./src/index.js",
devtool: "none", // Add "source-map" in development mode for debugging
devtool: "none", // Use "source-map" for development
module: {
rules: [
{
Expand All @@ -19,31 +18,30 @@ module.exports = {
},
{
test: /\.(png|jpe?g|gif|svg|woff2?|ttf|eot)$/i,
type: "asset", // Replaces file-loader for modern Webpack
parser: {
dataUrlCondition: {
maxSize: 8 * 1024, // Inline files smaller than 8 KB
use: [
{
loader: "file-loader",
options: {
name: "assets/[hash].[ext]",
},
},
},
generator: {
filename: "assets/[hash][ext][query]", // Output assets in an organized folder
},
],
},
],
},
output: {
filename: "[name].[contenthash].js", // Use content hashes for caching
chunkFilename: "[name].[contenthash].js", // Dynamic imports use hashed filenames
filename: "[name].[contenthash].js",
chunkFilename: "[name].[contenthash].js",
path: path.resolve(__dirname, "build"),
publicPath: "/console/", // Serve files from the correct base path
publicPath: "/console/",
},
optimization: {
runtimeChunk: "single", // Extract runtime into its own chunk
moduleIds: "deterministic", // Consistent hashes for modules
runtimeChunk: "single",
moduleIds: "hashed", // Compatible with Webpack 4.x
splitChunks: {
chunks: "all",
minSize: 30000, // Minimum size for a chunk (e.g., 30 KB)
maxSize: 250000, // Maximum size for a chunk (e.g., 250 KB)
minSize: 30000,
maxSize: 250000,
minChunks: 1,
maxAsyncRequests: 30,
maxInitialRequests: 30,
Expand All @@ -52,23 +50,21 @@ module.exports = {
test: /[\\/]node_modules[\\/]/,
name: "vendors",
chunks: "all",
priority: -10,
},
common: {
test: /[\\/]src[\\/]/,
name: "common",
minChunks: 2,
priority: -20,
},
},
},
},
plugins: [
new CleanWebpackPlugin(), // Cleans build folder before each build
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
inject: true,
template: "public/index.html", // Use the template file for the HTML
scriptLoading: "defer", // Load scripts with defer for better performance
template: "public/index.html",
scriptLoading: "defer",
}),
],
};

0 comments on commit 01350c4

Please sign in to comment.