mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-17 16:00:14 +01:00
chore(r5): dependencies update, couple of fixes
This commit is contained in:
parent
44fe93a0c6
commit
98097f5e27
18 changed files with 138 additions and 115 deletions
|
|
@ -2,18 +2,18 @@ function HtmlElementsPlugin(locations) {
|
|||
this.locations = locations;
|
||||
}
|
||||
|
||||
HtmlElementsPlugin.prototype.apply = function(compiler) {
|
||||
HtmlElementsPlugin.prototype.apply = function (compiler) {
|
||||
var self = this;
|
||||
compiler.plugin('compilation', function(compilation) {
|
||||
compiler.plugin('compilation', function (compilation) {
|
||||
compilation.options.htmlElements = compilation.options.htmlElements || {};
|
||||
|
||||
compilation.plugin('html-webpack-plugin-before-html-generation', function(htmlPluginData, callback) {
|
||||
compilation.plugin('html-webpack-plugin-before-html-generation', function (htmlPluginData, callback) {
|
||||
const locations = self.locations;
|
||||
|
||||
if (locations) {
|
||||
const publicPath = htmlPluginData.assets.publicPath;
|
||||
|
||||
Object.getOwnPropertyNames(locations).forEach(function(loc) {
|
||||
Object.getOwnPropertyNames(locations).forEach(function (loc) {
|
||||
compilation.options.htmlElements[loc] = getHtmlElementString(locations[loc], publicPath);
|
||||
});
|
||||
}
|
||||
|
|
@ -42,11 +42,15 @@ function createTag(tagName, attrMap, publicPath) {
|
|||
publicPath = publicPath || '';
|
||||
|
||||
// add trailing slash if we have a publicPath and it doesn't have one.
|
||||
if (publicPath && !RE_ENDS_WITH_BS.test(publicPath)) publicPath += '/';
|
||||
if (publicPath && !RE_ENDS_WITH_BS.test(publicPath)) {
|
||||
publicPath += '/';
|
||||
}
|
||||
|
||||
const attributes = Object.getOwnPropertyNames(attrMap)
|
||||
.filter(function(name) { return name[0] !== '='; } )
|
||||
.map(function(name) {
|
||||
.filter(function (name) {
|
||||
return name[0] !== '=';
|
||||
})
|
||||
.map(function (name) {
|
||||
var value = attrMap[name];
|
||||
|
||||
if (publicPath) {
|
||||
|
|
@ -88,14 +92,16 @@ function createTag(tagName, attrMap, publicPath) {
|
|||
*/
|
||||
function getHtmlElementString(dataSource, publicPath) {
|
||||
return Object.getOwnPropertyNames(dataSource)
|
||||
.map(function(name) {
|
||||
.map(function (name) {
|
||||
if (Array.isArray(dataSource[name])) {
|
||||
return dataSource[name].map(function(attrs) { return createTag(name, attrs, publicPath); } );
|
||||
return dataSource[name].map(function (attrs) {
|
||||
return createTag(name, attrs, publicPath);
|
||||
});
|
||||
} else {
|
||||
return [ createTag(name, dataSource[name], publicPath) ];
|
||||
return [createTag(name, dataSource[name], publicPath)];
|
||||
}
|
||||
})
|
||||
.reduce(function(arr, curr) {
|
||||
.reduce(function (arr, curr) {
|
||||
return arr.concat(curr);
|
||||
}, [])
|
||||
.join('\n\t');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue