How to use the webpack-sources.ConcatSource 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 fossasia / susper.com / node_modules / webpack / lib / MainTemplate.js View on Github external
this.plugin("render", (bootstrapSource, chunk, hash, moduleTemplate, dependencyTemplates) => {
			const source = new ConcatSource();
			source.add("/******/ (function(modules) { // webpackBootstrap\n");
			source.add(new PrefixSource("/******/", bootstrapSource));
			source.add("/******/ })\n");
			source.add("/************************************************************************/\n");
			source.add("/******/ (");
			const modules = this.renderChunkModules(chunk, moduleTemplate, dependencyTemplates, "/******/ ");
			source.add(this.applyPluginsWaterfall("modules", modules, chunk, hash, moduleTemplate, dependencyTemplates));
			source.add(")");
			return source;
		});
		this.plugin("local-vars", (source, chunk, hash) => {
github kaliberjs / build / library / webpack-plugins / source-map-plugin.js View on Github external
Object.keys(assets).forEach(name => {
            const asset = assets[name]
            const map = asset.map()
            if (map) {

              // make sure sources in the source map are timestamped, this helps with hot reloading
              const now = Date.now()
              map.sources = map.sources.map(source => source + (source.includes('?') ? '&' : '?') + now)

              const [startComment, endComment] = name.endsWith('.css') ? ['/*', ' */'] : ['//', '']
              assets[name] = new ConcatSource(asset, `\n${startComment}# sourceMappingURL=${path.basename(name)}.map${endComment}\n`)
              assets[name + '.map'] = new RawSource(JSON.stringify(map))
            }
          })
        })
github appcelerator / titanium-angular / packages / webpack-dev-titanium / lib / plugins / JsonpChunkTemplatePlugin.js View on Github external
chunkTemplate.plugin('render', function (modules, chunk) {
			const jsonpFunction = this.outputOptions.jsonpFunction;
			const source = new ConcatSource();
			source.add(`${jsonpFunction}(${JSON.stringify(chunk.ids)},`);
			source.add(modules);
			const entries = [ chunk.entryModule ].filter(Boolean).map(m => m.id);
			if (entries.length > 0) {
				source.add(`,${JSON.stringify(entries)}`);
			}
			source.add(')');
			return source;
		});
		chunkTemplate.plugin('hash', function (hash) {
github enigmampc / secret-contracts / node_modules / webpack / lib / SetVarMainTemplatePlugin.js View on Github external
compilation.templatesPlugin("render-with-entry", (source, chunk, hash) => {
			const varExpression = mainTemplate.applyPluginsWaterfall("asset-path", this.varExpression, {
				hash,
				chunk
			});
			if(this.copyObject) {
				return new ConcatSource(`(function(e, a) { for(var i in a) e[i] = a[i]; }(${varExpression}, `, source, "))");
			} else {
				const prefix = `${varExpression} =\n`;
				return new ConcatSource(prefix, source);
			}
		});
		mainTemplate.plugin("global-hash-paths", (paths) => {
github decentraland / explorer / kernel / packages / decentraland-rpc / bin / compile.ts View on Github external
compilation.hooks.afterOptimizeChunkAssets.tap('ESModulePlugin', (chunks) => {
        for (const chunk of chunks) {
          if (!chunk.canBeInitial()) {
            continue
          }

          for (const file of chunk.files) {
            compilation.assets[file] = new ConcatSource(
              compilation.assets[file],
              '\n',
              `export default ${this.options.exportedMember};`
            )
          }
        }
      })
    })
github johandb / svg-drawing-tool / node_modules / webpack / lib / BannerPlugin.js View on Github external
basename = filename;
						} else {
							basename = filename.substr(lastSlashIndex + 1);
						}

						const data = {
							hash,
							chunk,
							filename,
							basename,
							query
						};

						const comment = compilation.getPath(banner(data), data);

						compilation.assets[file] = new ConcatSource(
							comment,
							"\n",
							compilation.assets[file]
						);
					}
				}
			});
		});
github krhougs / mina-webpack-plugin / packages / core / src / applyChunkAssets.js View on Github external
if (config.options?.template) {
            const key = c.name + '.wxml'
            compilation.assets[key] = compilation.assets[key]
              ? new ConcatSource(compilation.assets[key], '\n', config.content)
              : new ConcatSource(config.content)
          } else if (config.options?.stylesheets || config.__MINA?.options.stylesheets) {
            const key = 'app.wxss'
            if (config.__MINA?.options.cssModules) {
              compilation.assets[key] = compilation.assets[key]
                ? new ConcatSource(compilation.assets[key], '\n', config.__MINA.stylesheets)
                : new ConcatSource(config.__MINA.stylesheets)
            } else {
              compilation.assets[key] = compilation.assets[key]
                ? new ConcatSource(compilation.assets[key], '\n', config.content)
                : new ConcatSource(config.content)
            }
          }
        }
      }
    }
  }
}
github daviddbarrero / Ionic-4-firebase / node_modules / webpack / lib / UmdMainTemplatePlugin.js View on Github external
}

			let amdFactory;
			if(optionalExternals.length > 0) {
				const wrapperArguments = externalsArguments(requiredExternals);
				const factoryArguments = requiredExternals.length > 0 ?
					externalsArguments(requiredExternals) + ", " + externalsRootArray(optionalExternals) :
					externalsRootArray(optionalExternals);
				amdFactory = `function webpackLoadOptionalExternalModuleAmd(${wrapperArguments}) {\n` +
					`			return factory(${factoryArguments});\n` +
					"		}";
			} else {
				amdFactory = "factory";
			}

			return new ConcatSource(new OriginalSource(
				"(function webpackUniversalModuleDefinition(root, factory) {\n" +
				(this.auxiliaryComment &&
					typeof this.auxiliaryComment === "string" ?
					"   //" + this.auxiliaryComment + "\n" :
					this.auxiliaryComment.commonjs2 ?
					"   //" + this.auxiliaryComment.commonjs2 + "\n" :
					""
				) +
				"	if(typeof exports === 'object' && typeof module === 'object')\n" +
				"		module.exports = factory(" + externalsRequireArray("commonjs2") + ");\n" +
				(this.auxiliaryComment &&
					typeof this.auxiliaryComment === "string" ?
					"   //" + this.auxiliaryComment + "\n" :
					this.auxiliaryComment.amd ?
					"   //" + this.auxiliaryComment.amd + "\n" :
					""
github romainberger / webpack-rtl-plugin / dist / index.js View on Github external
compilation.assets[asset] = new _webpackSources.ConcatSource(output.css);
            });

            if (match) {
              var rtlMinify = _cssnano2.default.process(rtlSource, nanoOptions).then(function (output) {
                compilation.assets[filename] = new _webpackSources.ConcatSource(output.css);
                rtlFiles.push(filename);
              });

              minify = Promise.all([minify, rtlMinify]);
            }

            return minify;
          });
        } else if (match) {
          compilation.assets[filename] = new _webpackSources.ConcatSource(rtlSource);
          rtlFiles.push(filename);
        }
      });
github realywithoutname / mini-program-webpack-loader / new / MiniPlugin.js View on Github external
compilation.hooks.additionalAssets.tapAsync('MiniPlugin', callback => {
      compilation.assets['webpack-require.js'] = new ConcatSource(
        fs.readFileSync(join(__dirname, './lib/require.js'), 'utf8')
      )
      callback()
    })