nav tabs on admin dashboard

This commit is contained in:
2019-03-07 00:20:34 -06:00
parent f73d6ae228
commit e4f473f376
11661 changed files with 216240 additions and 1544253 deletions

View File

@@ -4,33 +4,54 @@
*/
"use strict";
const asyncLib = require("async");
const asyncLib = require("neo-async");
const PrefetchDependency = require("./dependencies/PrefetchDependency");
const NormalModule = require("./NormalModule");
class AutomaticPrefetchPlugin {
apply(compiler) {
compiler.plugin("compilation", (compilation, params) => {
const normalModuleFactory = params.normalModuleFactory;
/** @typedef {import("./Compiler")} Compiler */
compilation.dependencyFactories.set(PrefetchDependency, normalModuleFactory);
});
class AutomaticPrefetchPlugin {
/**
* Apply the plugin
* @param {Compiler} compiler Webpack Compiler
* @returns {void}
*/
apply(compiler) {
compiler.hooks.compilation.tap(
"AutomaticPrefetchPlugin",
(compilation, { normalModuleFactory }) => {
compilation.dependencyFactories.set(
PrefetchDependency,
normalModuleFactory
);
}
);
let lastModules = null;
compiler.plugin("after-compile", (compilation, callback) => {
compiler.hooks.afterCompile.tap("AutomaticPrefetchPlugin", compilation => {
lastModules = compilation.modules
.filter(m => m instanceof NormalModule)
.map(m => ({
.map((/** @type {NormalModule} */ m) => ({
context: m.context,
request: m.request
}));
callback();
});
compiler.plugin("make", (compilation, callback) => {
if(!lastModules) return callback();
asyncLib.forEach(lastModules, (m, callback) => {
compilation.prefetch(m.context || compiler.context, new PrefetchDependency(m.request), callback);
}, callback);
});
compiler.hooks.make.tapAsync(
"AutomaticPrefetchPlugin",
(compilation, callback) => {
if (!lastModules) return callback();
asyncLib.forEach(
lastModules,
(m, callback) => {
compilation.prefetch(
m.context || compiler.context,
new PrefetchDependency(m.request),
callback
);
},
callback
);
}
);
}
}
module.exports = AutomaticPrefetchPlugin;