UNDERSTOOD!
The root of the problem stemmed from my use of webpack-node-externals in my shared configuration.
To delve deeper into the solution, please refer to both my question and answer on this matter by visiting: Webpack - Excluding node_modules with also keep a separated browser and server management. This will provide more comprehensive details.
In summary, here are the steps I took:
- Installation of requireJS ==> http://requirejs.org/docs/node.html
- Elimination of
externals: [nodeExternals()], // in order to ignore all modules in node_modules folder
from my general webpack configuration and transferring it under my server setup (accomplished prior to posing the question, yet incredibly crucial) [refer to webpack.config.js content in the linked inquiry above or in the snippet provided]
- Inclusion of
target: 'node',
prior to my previous externals mention within my server-side segment (executed before raising the question, however an essential step) [see webpack.config.js content in the linked question above or in the excerpt below]
This ensures the target remains 'web' for the browser side (default target), transitioning to 'node' solely for the server
- Manually executed webpack config vendor command via PowerShell using
webpack --config webpack.config.vendor.js
- Manually ran webpack config command through PowerShell employing
webpack --config webpack.config.js
These actions proved effective for me! Hopefully, they will be beneficial to anyone who happens upon this question while facing the same dilemma!
webpack.config.js snippet:
const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const AotPlugin = require('@ngtools/webpack').AotPlugin;
const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin;
var nodeExternals = require('webpack-node-externals');
module.exports = (env) => {
// Configuration common to client-side and server-side bundles
const isDevBuild = !(env && env.prod);
const sharedConfig = {
//removed from here, moved below.
//externals: [nodeExternals()], // in order to ignore all modules in node_modules folder
stats: { modules: false },
context: __dirname,
resolve: { extensions: [ '.js', '.ts' ] },
output: {
filename: '[name].js',
publicPath: 'dist/'
},
module: {
rules: [
{ test: /\.ts$/, use: isDevBuild ? ['awesome-typescript-loader?silent=true', 'angular2-template-loader', 'angular2-router-loader'] : '@ngtools/webpack' },
{ test: /\.html$/, use: 'html-loader?minimize=false' },
{ test: /\.css$/, use: [ 'to-string-loader', 'style-loader', isDevBuild ? 'css-loader' : 'css-loader?minimize' ] },
{ test: /\.(png|jpg|jpeg|gif|svg)$/, use: 'url-loader?limit=25000' }
]
},
plugins: [new CheckerPlugin()]
};
// Client-side bundle settings for browsers
const clientBundleOutputDir = './wwwroot/dist';
const clientBundleConfig = merge(sharedConfig, {
entry: { 'main-client': './ClientApp/boot.browser.ts' },
output: { path: path.join(__dirname, clientBundleOutputDir) },
plugins: [
new webpack.DllReferencePlugin({
context: __dirname,
manifest: require('./wwwroot/dist/vendor-manifest.json')
})
].concat(isDevBuild ? [
new webpack.SourceMapDevToolPlugin({
filename: '[file].map',
moduleFilenameTemplate: path.relative(clientBundleOutputDir, '[resourcePath]')
})
] : [
new webpack.optimize.UglifyJsPlugin(),
new AotPlugin({
tsConfigPath: './tsconfig.json',
entryModule: path.join(__dirname, 'ClientApp/app/app.browser.module#AppModule'),
exclude: ['./**/*.server.ts']
})
])
});
// Server-side (prerendering) bundle configuration for Node environment
const serverBundleConfig = merge(sharedConfig, {
resolve: { mainFields: ['main'] },
entry: { 'main-server': './ClientApp/boot.server.ts' },
plugins: [
new webpack.DllReferencePlugin({
context: __dirname,
manifest: require('./ClientApp/dist/vendor-manifest.json'),
sourceType: 'commonjs2',
name: './vendor'
})
].concat(isDevBuild ? [] : [
new AotPlugin({
tsConfigPath: './tsconfig.json',
entryModule: path.join(__dirname, 'ClientApp/app/app.server.module#AppModule'),
exclude: ['./**/*.browser.ts']
})
]),
output: {
libraryTarget: 'commonjs',
path: path.join(__dirname, './ClientApp/dist')
},
target: 'node',
externals: [nodeExternals()],
devtool: 'inline-source-map'
});
return [clientBundleConfig, serverBundleConfig];
};