I've spent several hours trying to troubleshoot this persistent error, exhausting all online resources for solutions. The issue arises consistently with every module of Angular Material
only during the build process using --env.prod
. The webpack configuration files were initially generated by the Asp.Net Core 2 Angular template
, and later modified in an attempt to implement fixes.
webpack.config.json
:
module.exports = (env) =>
{
// Common configuration shared between client-side and server-side bundles
const isDevBuild = !(env && env.prod);
const sharedConfig = {
stats: { modules: false },
context: __dirname,
resolve: { extensions: ['.js', '.ts'], modules: isDevBuild ? [] : [ "node_modules" ] },
output: {
filename: '[name].js',
publicPath: 'dist/'
},
// Module rules...
plugins: [new CheckerPlugin()]
};
// Client-side bundle configuration for browsers
const clientBundleOutputDir = './wwwroot/dist';
const clientBundleConfig = merge(sharedConfig, {
entry: { 'main-client': './ClientApp/boot.browser.ts' },
output: { path: path.join(__dirname, clientBundleOutputDir) },
// Additional plugins based on build type
});
// Server-side bundle configuration for Node environment
const serverBundleConfig = merge(sharedConfig, {
// More configurations specific to server-side setup
});
return [clientBundleConfig, serverBundleConfig];
};
Webpack commands:
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod --verbose" />
<Exec Command="node node_modules/webpack/bin/webpack.js --env.prod --verbose" />