Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if ((stylesSourceMap || scriptsSourceMap) &&
buildOptions.evalSourceMap &&
!stylesOptimization &&
!scriptsOptimization) {
// Produce eval sourcemaps for development with serve, which are faster.
isEval = true;
}
if (buildOptions.subresourceIntegrity) {
extraPlugins.push(new SubresourceIntegrityPlugin({
hashFuncNames: ['sha384'],
}));
}
if (buildOptions.extractLicenses) {
extraPlugins.push(new LicenseWebpackPlugin({
stats: {
warnings: false,
errors: false,
},
perChunkOutput: false,
outputFilename: `3rdpartylicenses.txt`,
}));
}
if (!isEval && (scriptsSourceMap || stylesSourceMap)) {
extraPlugins.push(getSourceMapDevTool(
scriptsSourceMap,
stylesSourceMap,
wco.differentialLoadingMode ? true : hiddenSourceMap,
));
}
// Copy the worker script into assets.
const workerContents = fs.readFileSync(workerPath).toString();
extraPlugins.push(new StaticAssetPlugin('worker-basic.min.js', workerContents));
// Add a script to index.html that registers the service worker.
// TODO(alxhub): inline this script somehow.
entryPoints['sw-register'] = [registerPath];
}
}
extraPlugins.push(new BundleBudgetPlugin({
budgets: appConfig.budgets
}));
if (buildOptions.extractLicenses) {
extraPlugins.push(new LicenseWebpackPlugin({
pattern: /^(MIT|ISC|BSD.*)$/,
suppressErrors: true,
perChunkOutput: false,
outputFilename: `3rdpartylicenses.txt`
}));
}
const uglifyCompressOptions: any = {
// Disabled because of an issue with Mapbox GL when using the Webpack node global and UglifyJS:
// https://github.com/mapbox/mapbox-gl-js/issues/4359#issuecomment-303880888
// https://github.com/angular/angular-cli/issues/5804
// https://github.com/angular/angular-cli/pull/7931
typeofs : false
};
if (buildOptions.buildOptimizer) {
],
watch: options.watch,
watchOptions: {
poll: options.poll
},
stats: getStatsConfig(options)
};
const extraPlugins: webpack.Plugin[] = [];
if (options.progress) {
extraPlugins.push(new ProgressPlugin());
}
if (options.extractLicenses) {
extraPlugins.push((new LicenseWebpackPlugin({
stats: {
errors: false
},
perChunkOutput: false,
outputFilename: `3rdpartylicenses.txt`
}) as unknown) as webpack.Plugin);
}
// process asset entries
if (options.assets) {
const copyWebpackPluginPatterns = options.assets.map((asset: any) => {
return {
context: asset.input,
// Now we remove starting slash to make Webpack place it from the output root.
to: asset.output,
ignore: asset.ignore,
if (buildOptions.evalSourceMap && !buildOptions.optimization) {
// Produce eval sourcemaps for development with serve, which are faster.
sourcemaps = 'eval';
}
else {
// Produce full separate sourcemaps for production.
sourcemaps = 'source-map';
}
}
if (buildOptions.subresourceIntegrity) {
extraPlugins.push(new SubresourceIntegrityPlugin({
hashFuncNames: ['sha384']
}));
}
if (buildOptions.extractLicenses) {
extraPlugins.push(new license_webpack_plugin_1.LicenseWebpackPlugin({
pattern: /.*/,
suppressErrors: true,
perChunkOutput: false,
outputFilename: `3rdpartylicenses.txt`
}));
}
const globalStylesBundleNames = utils_1.normalizeExtraEntryPoints(buildOptions.styles, 'styles')
.map(style => style.bundleName);
return {
devtool: sourcemaps,
resolve: {
mainFields: [
...(wco.supportES2015 ? ['es2015'] : []),
'browser', 'module', 'main'
]
},
if (isScriptOptimizeOn) {
webpackConfig.optimization = {
minimizer: [createTerserPlugin(esm)],
runtimeChunk: true
};
}
const extraPlugins: webpack.Plugin[] = [];
if (options.progress) {
extraPlugins.push(new ProgressPlugin());
}
if (options.extractLicenses) {
extraPlugins.push((new LicenseWebpackPlugin({
stats: {
errors: false
},
perChunkOutput: false,
outputFilename: `3rdpartylicenses.txt`
}) as unknown) as webpack.Plugin);
}
// process asset entries
if (options.assets) {
const copyWebpackPluginPatterns = options.assets.map((asset: any) => {
return {
context: asset.input,
// Now we remove starting slash to make Webpack place it from the output root.
to: asset.output,
ignore: asset.ignore,
) {
// Produce eval sourcemaps for development with serve, which are faster.
isEval = true;
}
if (buildOptions.subresourceIntegrity) {
extraPlugins.push(
new SubresourceIntegrityPlugin({
hashFuncNames: ['sha384']
})
);
}
if (buildOptions.extractLicenses) {
extraPlugins.push(
new LicenseWebpackPlugin({
stats: {
warnings: false,
errors: false
},
perChunkOutput: false,
outputFilename: `3rdpartylicenses.txt`
})
);
}
if (!isEval && (scriptsSourceMap || stylesSourceMap)) {
extraPlugins.push(
getSourceMapDevTool(
!!scriptsSourceMap,
!!stylesSourceMap,
hiddenSourceMap
if (!isModernSw) {
throw new Error(stripIndent`
The installed version of @angular/service-worker is ${swVersion}. This version of the CLI
requires the @angular/service-worker version to satisfy ${NEW_SW_VERSION}. Please upgrade
your service worker version.
`);
}
}
extraPlugins.push(new BundleBudgetPlugin({
budgets: appConfig.budgets
}));
if (buildOptions.extractLicenses) {
extraPlugins.push(new LicenseWebpackPlugin({
pattern: /^(MIT|ISC|BSD.*)$/,
suppressErrors: true,
perChunkOutput: false,
outputFilename: `3rdpartylicenses.txt`
}));
}
return {
plugins: extraPlugins,
};
}
filename: '[file].map[query]',
moduleFilenameTemplate: '[resource-path]',
fallbackModuleFilenameTemplate: '[resource-path]?[hash]',
sourceRoot: 'webpack:///'
}));
}
}
if (buildOptions.subresourceIntegrity) {
extraPlugins.push(new SubresourceIntegrityPlugin({
hashFuncNames: ['sha384']
}));
}
if (buildOptions.extractLicenses) {
extraPlugins.push(new LicenseWebpackPlugin({
pattern: /.*/,
suppressErrors: true,
perChunkOutput: false,
outputFilename: `3rdpartylicenses.txt`
}));
}
const globalStylesEntries = extraEntryParser(appConfig.styles, appRoot, 'styles')
.map(style => style.entry);
return {
resolve: {
mainFields: [
...(wco.supportES2015 ? ['es2015'] : []),
'browser', 'module', 'main'
]
function extractDependencies() {
if (!LICENSE_CHECK) {
return [];
}
return [
new LicenseWebpackPlugin({
outputFilename: 'dependencies.json',
perChunkOutput: false,
renderLicenses: (modules) => {
const usedModules = modules.reduce((result, m) => {
const {
name,
version
} = m.packageJson;
const id = `${name}@${version}`;
return {
...result,
[id]: true
extraPlugins.push(new index_html_webpack_plugin_1.IndexHtmlWebpackPlugin({
input: path.resolve(root, buildOptions.index),
output: path.basename(buildOptions.index),
baseHref: buildOptions.baseHref,
entrypoints: package_chunk_sort_1.generateEntryPoints(buildOptions),
deployUrl: buildOptions.deployUrl,
sri: buildOptions.subresourceIntegrity,
}));
}
if (buildOptions.subresourceIntegrity) {
extraPlugins.push(new SubresourceIntegrityPlugin({
hashFuncNames: ['sha384'],
}));
}
if (buildOptions.extractLicenses) {
extraPlugins.push(new license_webpack_plugin_1.LicenseWebpackPlugin({
stats: {
warnings: false,
errors: false,
},
perChunkOutput: false,
outputFilename: `3rdpartylicenses.txt`,
}));
}
if (!isEval && (scriptsSourceMap || stylesSourceMap)) {
extraPlugins.push(utils_1.getSourceMapDevTool(scriptsSourceMap, stylesSourceMap, hiddenSourceMap));
}
const globalStylesBundleNames = utils_1.normalizeExtraEntryPoints(buildOptions.styles, 'styles')
.map(style => style.bundleName);
return {
devtool: isEval ? 'eval' : false,
resolve: {