Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@idrinth-api-bench/inline-critical-css

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@idrinth-api-bench/inline-critical-css - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

2

package.json
{
"name": "@idrinth-api-bench/inline-critical-css",
"version": "1.0.2",
"version": "1.1.0",
"description": "",

@@ -5,0 +5,0 @@ "type": "module",

import { parse, stringify, } from 'css';
import { readdirSync, writeFileSync, readFileSync, } from 'fs';
import { createHash, } from "crypto";
import minify from "css-minify";
import { createHash, } from 'crypto';
import minify from 'css-minify';
const source = `${process.cwd()}/dist/assets`;

@@ -87,3 +87,13 @@ const critical = [];

const finalHash = hash.digest('hex');
writeFileSync(`${source}/critical-${finalHash}.css`, await minify(stringify({ type: 'stylesheet', stylesheet: { rules: critical, } })));
writeFileSync(`${source}/../index.html`, readFileSync(`${source}/../index.html`, 'utf8').replace(/<\/head>/iug, `<link rel="stylesheet" href="/assets/critical-${finalHash}.css"/></head>`), 'utf8');
const index = readFileSync(`${source}/../index.html`, 'utf8');
const styles = await minify(stringify({
type: 'stylesheet',
stylesheet: { rules: critical, }
}));
if (process.argv.indexOf('--inline') !== -1) {
writeFileSync(`${source}/../index.html`, index.replace(/<\/title>/iug, `</title><style>${styles}</style>`), 'utf8');
}
else {
writeFileSync(`${source}/critical-${finalHash}.css`, styles);
writeFileSync(`${source}/../index.html`, index.replace(/<\/title>/iug, `</title><link rel="stylesheet" href="/assets/critical-${finalHash}.css"/>`), 'utf8');
}

@@ -12,4 +12,4 @@ import {

createHash,
} from "crypto";
import minify from "css-minify"
} from 'crypto';
import minify from 'css-minify'

@@ -97,7 +97,20 @@ const source = `${ process.cwd() }/dist/assets`;

const finalHash = hash.digest('hex');
writeFileSync(`${source}/critical-${finalHash}.css`, await minify(stringify({type: 'stylesheet', stylesheet: {rules: critical,}})));
writeFileSync(
`${source}/../index.html`,
readFileSync(`${source}/../index.html`, 'utf8').replace(/<\/head>/iug, `<link rel="stylesheet" href="/assets/critical-${finalHash}.css"/></head>`),
'utf8',
)
const index = readFileSync(`${source}/../index.html`, 'utf8');
const styles = await minify(stringify({
type: 'stylesheet',
stylesheet: {rules: critical,}
}));
if (process.argv.indexOf('--inline') !== -1) {
writeFileSync(
`${source}/../index.html`,
index.replace(/<\/title>/iug, `</title><style>${styles}</style>`),
'utf8',
);
} else {
writeFileSync(`${source}/critical-${finalHash}.css`, styles);
writeFileSync(
`${source}/../index.html`,
index.replace(/<\/title>/iug, `</title><link rel="stylesheet" href="/assets/critical-${finalHash}.css"/>`),
'utf8',
);
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc