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

@@ -5,50 +5,100 @@
"use strict";
const ConcatSource = require("webpack-sources").ConcatSource;
const { ConcatSource } = require("webpack-sources");
const Template = require("./Template");
/** @typedef {import("./Compilation")} Compilation */
/**
* @typedef {Object} AmdMainTemplatePluginOptions
* @param {string=} name the library name
* @property {boolean=} requireAsWrapper
*/
class AmdMainTemplatePlugin {
constructor(name) {
this.name = name;
/**
* @param {AmdMainTemplatePluginOptions} options the plugin options
*/
constructor(options) {
if (!options || typeof options === "string") {
this.name = options;
this.requireAsWrapper = false;
} else {
this.name = options.name;
this.requireAsWrapper = options.requireAsWrapper;
}
}
/**
* @param {Compilation} compilation the compilation instance
* @returns {void}
*/
apply(compilation) {
const mainTemplate = compilation.mainTemplate;
const { mainTemplate, chunkTemplate } = compilation;
compilation.templatesPlugin("render-with-entry", (source, chunk, hash) => {
const externals = chunk.getModules().filter((m) => m.external);
const externalsDepsArray = JSON.stringify(externals.map((m) =>
typeof m.request === "object" ? m.request.amd : m.request
));
const externalsArguments = externals.map((m) =>
Template.toIdentifier(`__WEBPACK_EXTERNAL_MODULE_${m.id}__`)
).join(", ");
const onRenderWithEntry = (source, chunk, hash) => {
const externals = chunk.getModules().filter(m => m.external);
const externalsDepsArray = JSON.stringify(
externals.map(m =>
typeof m.request === "object" ? m.request.amd : m.request
)
);
const externalsArguments = externals
.map(
m => `__WEBPACK_EXTERNAL_MODULE_${Template.toIdentifier(`${m.id}`)}__`
)
.join(", ");
if(this.name) {
const name = mainTemplate.applyPluginsWaterfall("asset-path", this.name, {
if (this.requireAsWrapper) {
return new ConcatSource(
`require(${externalsDepsArray}, function(${externalsArguments}) { return `,
source,
"});"
);
} else if (this.name) {
const name = mainTemplate.getAssetPath(this.name, {
hash,
chunk
});
return new ConcatSource(
`define(${JSON.stringify(name)}, ${externalsDepsArray}, function(${externalsArguments}) { return `, source, "});"
`define(${JSON.stringify(
name
)}, ${externalsDepsArray}, function(${externalsArguments}) { return `,
source,
"});"
);
} else if (externalsArguments) {
return new ConcatSource(
`define(${externalsDepsArray}, function(${externalsArguments}) { return `,
source,
"});"
);
} else if(externalsArguments) {
return new ConcatSource(`define(${externalsDepsArray}, function(${externalsArguments}) { return `, source, "});");
} else {
return new ConcatSource("define(function() { return ", source, "});");
}
});
};
mainTemplate.plugin("global-hash-paths", (paths) => {
if(this.name) paths.push(this.name);
for (const template of [mainTemplate, chunkTemplate]) {
template.hooks.renderWithEntry.tap(
"AmdMainTemplatePlugin",
onRenderWithEntry
);
}
mainTemplate.hooks.globalHashPaths.tap("AmdMainTemplatePlugin", paths => {
if (this.name) {
paths.push(this.name);
}
return paths;
});
mainTemplate.plugin("hash", (hash) => {
mainTemplate.hooks.hash.tap("AmdMainTemplatePlugin", hash => {
hash.update("exports amd");
hash.update(this.name);
if (this.name) {
hash.update(this.name);
}
});
}
}