Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const additionalPlugins = options.plugins || false;
let inline = true;
if ({}.hasOwnProperty.call(options, 'sourcemapInline')) {
inline = options.sourcemapInline;
}
const importOptions = {};
if (prepend) {
importOptions.prepend = prepend;
}
const plugins = [atImport(importOptions)];
if (useVars) {
plugins.push(vars({ strict: false }));
}
plugins.push(dedupe());
if (useExtend) {
plugins.push(inherit());
}
if (namespace) {
plugins.push(namespace(ns));
}
if (urlPrefix) {
plugins.push(url({ url: (urlString) =>
`${urlPrefix}${urlString}`,
}));
}
if (autopre) {
plugins.push(autoprefixer({ browsers }));
}
this.get().forEach((style) => {
let hasher = objectHash({ sort: true, coerce: true }).hash
let hash = hasher(style)
if (typeof cssHashes[ hash ] !== 'undefined' && typeof cssHashes[ hash ].result !== 'undefined') {
return iterations.push(cssHashes[ hash ].result)
}
let use = []
if (style.hasOwnProperty('variables')) {
use.push(postcssAdvancedVars({
variables: style.variables
}))
use.push(postcssCustomProps(style.variables))
} else {
use.push(postcssAdvancedVars())
use.push(postcssCustomProps())
}
cssHashes[ hash ] = {}
let viewports = this.getViewports()
if (style.hasOwnProperty('viewports')) {
viewports = style.viewports
}
use.push(postcssMedia({
importFrom: { customMedia: viewports }
}))
if (style.path) {
use.push(postcssPrefixUrl({
let stylePromise = new Promise((resolve, reject) => {
postcss()
.use(postcssVars())
.process(styles[ tagName ].editorCss)
.then((result) => {
resolve(result.css)
})
})
iterations.push(stylePromise)
c.use.filter(d => d.loader == 'postcss-loader').forEach(x => {
x.options.plugins.push(customProperties({ preserve: true }));
});
});
let hasher = objectHash({ sort: true, coerce: true }).hash
let hash = hasher(style)
if (typeof cssHashes[ hash ] !== 'undefined' && typeof cssHashes[ hash ].result !== 'undefined') {
return iterations.push(cssHashes[ hash ].result)
}
let use = []
if (style.hasOwnProperty('variables')) {
use.push(postcssAdvancedVars({
variables: style.variables
}))
use.push(postcssCustomProps(style.variables))
} else {
use.push(postcssAdvancedVars())
use.push(postcssCustomProps())
}
cssHashes[ hash ] = {}
let viewports = this.getViewports()
if (style.hasOwnProperty('viewports')) {
viewports = style.viewports
}
use.push(postcssMedia({
importFrom: { customMedia: viewports }
}))
if (style.path) {
use.push(postcssPrefixUrl({
useUrl: true,
prefix: style.path
}))