Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const processCss = (css: string, id: string): void => {
if ((!css || !/\S/.test(css)) && !emitEmpty) {
if (debug) this.warn('CSS empty, not emitting file');
return;
}
if (optimize) {
const cleancss = new CleanCSS({
sourceMap: false, // TODO: Add source map support
...(typeof optimize === 'object' ? optimize : {}),
});
const result = cleancss.minify(css);
for (const err of result.warnings) this.warn(err);
for (const err of result.errors) this.error(err);
// eslint-disable-next-line no-param-reassign
css = result.styles;
}
const name = id.replace(extname(id), '');
this.emitAsset(`${name}.css`, css);
match({ routes, history }, (error, redirectLocation, renderProps) => {
if (error) {
// response.status(500).send(error.message);
} else if (redirectLocation) {
// response.redirect(302, `${redirectLocation.pathname}${redirectLocation.search}`);
} else if (renderProps) {
response(template({
root: renderToString(),
css: new cleancss().minify(jss.sheets.toString()).styles,
jsBundle: clientAssets.main.js
}));
} else {
// response.status(404).send('Not found');
}
});
}
const renderTemplate = (element, options, generateCustomTemplate) => {
const bodyContent = ReactDOMServer.renderToStaticMarkup(element);
const minifiedHeadCSS = new CleanCSS().minify(options.headCSS || '').styles;
options = objectAssign({}, {
lang: sanitizer.escape(options.lang),
dir: sanitizer.escape(options.dir),
title: sanitizer.escape(options.title),
previewText: sanitizer.escape(options.previewText),
headCSS: CSS.raiseOnUnsafeCSS(minifiedHeadCSS, 'headCSS'),
bgColor: sanitizer.escape(options.bgColor)
}, {bodyContent: bodyContent});
return generateCustomTemplate ? (
generateCustomTemplate(options)
) : HTML4.generateDefaultTemplate(options);
};
applyPluginTheme (themeName) {
if (themeName && this.pluginThemes) {
const theme = this.pluginThemes[themeName]
if (theme) {
const $style = document.querySelector('style[name=plugins]')
const input = fs.readFileSync(theme.cssPath)
const output = new CleanCss().minify(input)
$style.innerHTML = output.styles
}
}
}
}
css (style) {
const file = require.resolve('vue-resize/dist/vue-resize.css')
style += fs.readFileSync(file, { encoding: 'utf8' })
fs.writeFileSync('dist/vue-virtual-scroller.css', new CleanCSS().minify(style).styles)
},
}),
var minify = function minify(cssSource, options) {
return new CleanCss(options).minify(cssSource).styles;
};
function minifyCSS(inPath: string, outPath: string, callback: Function, result: Object) {
var sourceMappingURL = result.css.match(/\n.+$/)[0];
result = new CleanCSS({
keepSpecialComments: 0,
roundingPrecision: -1,
sourceMap: JSON.stringify(result.map),
sourceMapInlineSources: true
}).minify(result.css);
zlib.gzip(result.styles + sourceMappingURL, function jsGzipHandler(e, code) {
if (e) {
return consoleError(e);
}
fs.writeFile(outPath, code, function jsWriteCompressedScriptHandler(styleErr) {
if (styleErr) {
return consoleError(styleErr);
}
fs.writeFile(outPath + '.map', result.sourceMap, function cssWriteMapHandler(mapErr) {
if (mapErr) {
return consoleError(mapErr);
export default function cssMin(data: Object): Object {
const sourceMappingURL = data.code.match(/\n.+$/)[0],
result = new CleanCSS({
keepSpecialComments: 0,
roundingPrecision,
sourceMap: data.map,
sourceMapInlineSources: true
}).minify(data.code);
return {code: result.styles + sourceMappingURL, map: result.sourceMap};
}
if (css.length === 0) {
return null;
}
const vp = options.vendorPrefixes;
if (vp) {
if (typeof vp === 'object') {
css = postcss([autoprefixer(vp)]).process(css).css;
} else {
css = postcss([autoprefixer]).process(css).css;
}
}
if (options.minify) {
css = new CleanCSS().minify(css).styles;
}
return css;
}
.then(result => {
let options = {
level: {
1: {
removeQuotes: false,
}
}
}
let output = new CleanCSS(options).minify(result.css);
let res = JSON.stringify(output.styles).replace(/"/g, "'");
let js = `export const CSSTEXT = "${res.slice(1, -1)}";`;
fs.writeFile('src/css/chartsCss.js', js);
});
});