How to use concat-with-sourcemaps - 6 common examples

To help you get started, we’ve selected a few concat-with-sourcemaps 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 callstack / haul / packages / haul-basic-bundle-webpack-plugin / src / WebpackBasicBundlePlugin.ts View on Github external
const {
          mainMap,
          mainSource: mainSourceFilename,
          asyncChunks,
        } = this.getFilenamesFromChunks(compilation.chunks);

        const sourceMappingRegex = /\/\/# sourceMappingURL=(.+)/;
        const mainSource = compilation.assets[mainSourceFilename].source();
        const sourceMappingMatch = new RegExp(sourceMappingRegex, 'g').exec(
          mainSource
        );

        // Concatenate all chunks and its source maps. Chunks source needs to have source mapping URL
        // removed, since it will be added at the end of the whole bundle.
        const concat = new Concat(true, mainSourceFilename, '\n');
        concat.add(
          mainSourceFilename,
          mainSource.replace(new RegExp(sourceMappingRegex, 'g'), ''),
          this.sourceMap ? compilation.assets[mainMap].source() : undefined
        );
        asyncChunks.forEach(chunk => {
          concat.add(
            chunk.source,
            (compilation.assets[chunk.source].source() as string).replace(
              new RegExp(sourceMappingRegex, 'g'),
              ''
            ),
            this.sourceMap ? compilation.assets[chunk.map].source() : undefined
          );
        });
github postcss / postcss / test / css-syntax-error.js View on Github external
test('uses source map', t => {
    let concat = new Concat(true, 'all.css');
    concat.add('a.css', 'a { }\n');
    concat.add('b.css', '\nb {\n');

    let error = parseError(concat.content, {
        from: 'build/all.css',
        map:  { prev: concat.sourceMap }
    });

    t.deepEqual(error.file, path.resolve('b.css'));
    t.deepEqual(error.line, 2);
    t.deepEqual(typeof error.source, 'undefined');

    t.deepEqual(error.input, {
        file:   path.resolve('build/all.css'),
        line:   3,
        column: 1,
github egoist / rollup-plugin-postcss / src / index.js View on Github external
const getExtracted = () => {
        const fileName =
          typeof postcssLoaderOptions.extract === 'string' ?
            path.relative(dir, postcssLoaderOptions.extract) :
            `${path.basename(file, path.extname(file))}.css`
        const concat = new Concat(true, fileName, '\n')
        const entries = Array.from(extracted.values())
        const { modules } = bundle[path.relative(dir, file)]

        if (modules) {
          const fileList = Object.keys(modules)
          entries.sort(
            (a, b) => fileList.indexOf(a.id) - fileList.indexOf(b.id)
          )
        }
        for (const res of entries) {
          const relative = path.relative(dir, res.id)
          const map = res.map || null
          if (map) {
            map.file = fileName
          }
          concat.add(relative, res.code, map)
github bitrix-tools / cli / src / tools / concat.js View on Github external
export default function concat(input: string[] = [], output: string) {
	if (Array.isArray(input) && input.length) {
		const concatenator = new Concat(generateSourceMap, output, separator);

		input
			.filter(existsSync)
			.forEach((filePath) => {
				const fileContent = readFileSync(filePath);
				const sourceMapPath = `${filePath}.map`;
				let sourceMapContent;

				if (existsSync(sourceMapPath)) {
					const mapContent = JSON.parse(readFileSync(sourceMapPath, encoding));

					mapContent.sources = mapContent.sources.map(sourcePath => (
						resolve(dirname(sourceMapPath), sourcePath)
					));

					sourceMapContent = JSON.stringify(mapContent);

concat-with-sourcemaps

Concatenate file contents with a custom separator and generate a source map

ISC
Latest version published 6 years ago

Package Health Score

67 / 100
Full package analysis

Popular concat-with-sourcemaps functions