Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
let sourceMapUseRule;
if ((scriptsSourceMap || stylesSourceMap) && vendorSourceMap) {
sourceMapUseRule = {
use: [
{
loader: 'source-map-loader'
}
]
};
}
let buildOptimizerUseRule;
if (buildOptions.buildOptimizer) {
extraPlugins.push(new BuildOptimizerWebpackPlugin());
buildOptimizerUseRule = {
use: [
{
loader: buildOptimizerLoaderPath,
options: { sourceMap: scriptsSourceMap }
}
]
};
}
// Allow loaders to be in a node_modules nested inside the devkit/build-angular package.
// This is important in case loaders do not get hoisted.
// If this file moves to another location, alter potentialNodeModules as well.
const loaderNodeModules = findAllNodeModules(__dirname, projectRoot);
loaderNodeModules.unshift('node_modules');
new CircularDependencyPlugin({
exclude: /[\\\/]node_modules[\\\/]/,
}),
);
}
if (options.optimization) {
webpackConfig.module.rules.push({
test: /\.js$/,
loader: '@angular-devkit/build-optimizer/webpack-loader',
options: {
sourceMap: options.sourceMap,
},
});
webpackConfig.plugins.push(new BuildOptimizerWebpackPlugin());
}
return webpackConfig;
}
},
],
},
plugins: [ngCompilerPlugin],
};
if (options.optimization) {
webpackConfig.module.rules.push({
test: /\.js$/,
loader: '@angular-devkit/build-optimizer/webpack-loader',
options: {
sourceMap: options.sourceMap,
},
});
webpackConfig.plugins.push(new BuildOptimizerWebpackPlugin());
}
return webpackConfig;
}