Skip to content

Instantly share code, notes, and snippets.

View karlfloersch's full-sized avatar
🐹
dogeeeeee

Karl Floersch karlfloersch

🐹
dogeeeeee
View GitHub Profile
@karlfloersch
karlfloersch / index.js
Created April 4, 2016 18:35 — forked from mogelbrod/index.js
Simple apply-loader module for webpack
var loaderUtils = require('loader-utils');
module.exports = function(source) {
this.cacheable && this.cacheable();
var query = loaderUtils.parseQuery(this.query);
var args = [];
// apply?config=key => sourceFn(require('webpack.config').key)
if (typeof query.config === 'string') {
if (!query.config in this.options)
@karlfloersch
karlfloersch / wrapAsFn.js
Last active March 16, 2016 21:00
Webpack loader that wraps a JS file in a function so that you can inject variables to be modified. Original Author: @IngwiePhoenix
var loaderUtils = require("loader-utils"); // https://www.npmjs.com/package/loader-utils
module.exports = function WrapAsFnLoader(source) {
var query = loaderUtils.parseQuery(this.query);
var exportVars = query.exports;
var exStmt = [];
// Build the local variables by using the exports property on the query.
// This allows us to turn a couple this-variables into locals.
// Use a string to indicate that you want to import it as the same name,
// alternatively, provide an array of key-value pairs: The key becomes the local var,