Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save TheLarkInn/5602da70d184340f7648566c6eb3a054 to your computer and use it in GitHub Desktop.
Save TheLarkInn/5602da70d184340f7648566c6eb3a054 to your computer and use it in GitHub Desktop.
Notes on functional webpack plugin creation
const createClass = () => {
return class {
constructor(options) { this.options = options || {}; }
};
}
const Plugin = (x) => (
return {
map: f => Plugin(f(x)),
fold: f => f(x),
inspect: () => `Plugin(${x})`
};
);
const Foo = createClass();
const bar = new Foo();
console.log(bar);
// WHAT IT TAKES NOW
class SomePlugin {
constructor(options) {
this.options = options || {};
}
apply(compiler) {
compiler.plugin("run", (compiler, callback) => {
console.log("THE WEBPACK COMPILER JUST STARTED");
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment