How to use the webpack-sources.SourceMapSource function in webpack-sources

To help you get started, we’ve selected a few webpack-sources examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rxweb / rxweb / rxweb.io / node_modules / @angular-devkit / build-angular / src / angular-cli-files / plugins / cleancss-webpack-plugin.js View on Github external
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;
                });
            });
github zeit / next.js / packages / next / build / webpack / plugins / terser-webpack-plugin / src / index.js View on Github external
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 => {
github athm-fe / create-autofe-app / packages / autofe-webpack / src / css-url-relative-plugin / index.js View on Github external
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;
      }
    })
github rei / rei-cedar-docs / node_modules / uglifyjs-webpack-plugin / dist / index.js View on Github external
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);
                }
              }
github csxiaoyaojianxian / JavaScriptStudy / 09-Tools / 01-webpack / node_modules / webpack / lib / NormalModule.js View on Github external
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);
	}
github flaviuse / mern-authentication / client / node_modules / webpack / lib / NormalModule.js View on Github external
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);
	}
github zeit / next.js / packages / next / build / webpack / plugins / css-minimizer-plugin.ts View on Github external
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)
                  }
                })
              })
github tamb / domponent / node_modules / webpack / lib / NormalModule.js View on Github external
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);
	}
github jake-101 / bael-template / node_modules / webpack / lib / NormalModule.js View on Github external
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);
	}