webpack-incremental-ident
Version:
Generate incremental class name for css loader
30 lines (24 loc) • 648 B
JavaScript
const getLocalIdent = require("./ident");
const { setupConfig, importLog, exportLog } = require("./config");
class IncrementalCSS {
constructor(options = {}) {
setupConfig(options);
importLog();
}
apply(compiler) {
if (compiler.hooks) {
compiler.hooks.afterEmit.tapAsync(
"WebpackIncrementalIdent",
this.handleAfterEmit,
);
} else {
compiler.plugin("after-emit", this.handleAfterEmit);
}
}
handleAfterEmit(_compilation, callback) {
exportLog();
callback();
}
}
IncrementalCSS.getLocalIdent = getLocalIdent;
module.exports = IncrementalCSS;