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

@senojs/rollup-plugin-style-inject

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@senojs/rollup-plugin-style-inject - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [0.2.0](https://github.com/senoteam/vite-plugin/compare/@senojs/rollup-plugin-style-inject@0.1.1...@senojs/rollup-plugin-style-inject@0.2.0) (2022-11-18)
### Features
* **style-inject:** 🌟 support for transform less files ([845ed09](https://github.com/senoteam/vite-plugin/commit/845ed09edc7b8c8e908af8c956b9b78f30cd638c))
## [0.1.1](https://github.com/senoteam/vite-plugin/compare/@senojs/rollup-plugin-style-inject@0.1.0...@senojs/rollup-plugin-style-inject@0.1.1) (2022-09-15)

@@ -8,0 +19,0 @@

20

index.js

@@ -6,10 +6,11 @@ import path from 'node:path'

if (!css || typeof document === 'undefined') return
const head = document.head
const head = document.head || document.querySelector('head')
const firstChild = head.querySelector(':first-child')
const style = document.createElement('style')
if (insertAt === 'top' && head.firstChild) {
head.insertBefore(style, head.firstChild)
style.appendChild(document.createTextNode(css))
if (insertAt === 'top' && firstChild) {
head.insertBefore(style, firstChild)
} else {
head.appendChild(style)
}
style.appendChild(document.createTextNode(css))
}

@@ -20,2 +21,3 @@ `

const cssCodes = []
const cssLangs = ['.css', '.less']
return {

@@ -25,7 +27,7 @@ name: '@senojs/rollup-plugin-style-inject',

transform(code, id) {
const isCSS = path.extname(id) === '.css'
const isCSS = cssLangs.includes(path.extname(id))
if (isCSS) {
cssCodes.push(code)
return { code: '', map: null }
}
return { code: isCSS ? '' : code, map: null }
},

@@ -35,3 +37,7 @@ footer: cssInjectorText,

if (chunk.isEntry) {
const injections = cssCodes.map((v) => `injectStyle(\`${v}\`, '${insertAt}')`).join('\n')
const cssString = cssCodes
.join('')
.replace(/ *\\9/g, '')
.replace(/\\(\d+)/g, '0o$1')
const injections = `injectStyle(\`${cssString}\`, '${insertAt}')`
return { code: code + injections, map: null }

@@ -38,0 +44,0 @@ }

{
"name": "@senojs/rollup-plugin-style-inject",
"version": "0.1.1",
"version": "0.2.0",
"description": "rollup-plugin-style-inject",
"type": "module",
"main": "index.js",
"engines": {
"node": ">=12"
},
"scripts": {

@@ -25,7 +28,7 @@ "test": "echo \"Error: no test specified\" && exit 1"

},
"homepage": "https://github.com/senoteam/vite-plugin#readme",
"homepage": "https://github.com/senoteam/vite-plugin/tree/main/packages/style-inject",
"publishConfig": {
"access": "public"
},
"gitHead": "c23a5d413f05ec2417b84c9384c6ff55aeba32c0"
"gitHead": "408e3c6866fe482fab8880ce8647bba6945a85a0"
}
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