Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (output.warnings && output.warnings.length > 0) {
compilation.warnings.push(...output.warnings);
hasWarnings = true;
}
if (output.errors && output.errors.length > 0) {
output.errors
.forEach((error) => compilation.errors.push(new Error(error)));
return;
}
// generally means invalid syntax so bail
if (hasWarnings && output.stats.minifiedSize === 0) {
return;
}
let newSource;
if (output.sourceMap) {
newSource = new webpack_sources_1.SourceMapSource(output.styles, file, output.sourceMap.toString(), content, map);
}
else {
newSource = new webpack_sources_1.RawSource(output.styles);
}
compilation.assets[file] = newSource;
});
});
compilation.errors.push(
TerserPlugin.buildError(
error,
file,
sourceMap,
new RequestShortener(compiler.context)
)
)
return
}
let outputSource
if (map) {
outputSource = new SourceMapSource(
code,
file,
JSON.parse(map),
input,
inputSourceMap
)
} else {
outputSource = new RawSource(code)
}
// Updating assets
processedAssets.add((compilation.assets[file] = outputSource))
// Handling warnings
if (warnings && warnings.length > 0) {
warnings.forEach(warning => {
pathname = pathname.substring(publicPath.length)
}
// get relative path
pathname = path.relative(dirname, pathname).replace(/\\/g, '/')
return `url(${pathname})`
}
// return original rule
return refer.rule
})
let newSource;
if (inputSourceMap) {
newSource = new SourceMapSource(
content,
name,
inputSourceMap,
input,
inputSourceMap,
true,
)
} else {
newSource = new RawSource(content);
}
assets[name] = newSource;
}
})
map = data.map,
code = data.code,
warnings = data.warnings,
extractedComments = data.extractedComments;
// Handling results
// Error case: add errors, and go to next file
if (error) {
compilation.errors.push(UglifyJsPlugin.buildError(error, file, sourceMap, requestShortener));
return;
}
var outputSource = void 0;
if (map) {
outputSource = new _webpackSources.SourceMapSource(code, file, JSON.parse(map), input, inputSourceMap);
} else {
outputSource = new _webpackSources.RawSource(code);
}
// Write extracted comments to commentsFile
if (commentsFile && extractedComments.length > 0) {
// Add a banner to the original file
if (_this.options.extractComments.banner !== false) {
var banner = _this.options.extractComments.banner || `For license information please see ${commentsFile}`;
if (typeof banner === 'function') {
banner = banner(commentsFile);
}
if (banner) {
outputSource = new _webpackSources.ConcatSource(`/*! ${banner} */\n`, outputSource);
}
}
createSourceForAsset(name, content, sourceMap) {
if(!sourceMap) {
return new RawSource(content);
}
if(typeof sourceMap === "string") {
return new OriginalSource(content, sourceMap);
}
return new SourceMapSource(content, name, sourceMap);
}
createSourceForAsset(name, content, sourceMap) {
if (!sourceMap) {
return new RawSource(content);
}
if (typeof sourceMap === "string") {
return new OriginalSource(content, sourceMap);
}
return new SourceMapSource(content, name, sourceMap);
}
return minify(input, postcssOptions).then(res => {
if (res.map) {
compilation.assets[file] = new SourceMapSource(
res.css,
file,
res.map.toJSON()
)
} else {
compilation.assets[file] = new RawSource(res.css)
}
})
})
createSourceForAsset(name, content, sourceMap) {
if (!sourceMap) {
return new RawSource(content);
}
if (typeof sourceMap === "string") {
return new OriginalSource(content, sourceMap);
}
return new SourceMapSource(content, name, sourceMap);
}
createSourceForAsset(name, content, sourceMap) {
if (!sourceMap) {
return new RawSource(content);
}
if (typeof sourceMap === "string") {
return new OriginalSource(content, sourceMap);
}
return new SourceMapSource(content, name, sourceMap);
}