astro-css-components
Advanced tools
Comparing version 0.3.1 to 0.4.0
@@ -9,4 +9,4 @@ import { getCSSForComponent } from "./utils.js" | ||
function addComponentForURL(url, component) { | ||
component = getCSSForComponent(component) | ||
function addComponentForURL(url, component, minify) { | ||
component = getCSSForComponent(component, minify) | ||
@@ -28,4 +28,4 @@ if (!(url in componentLibrary)) { | ||
function addGlobalComponent(component) { | ||
component = getCSSForComponent(component) | ||
function addGlobalComponent(component, minify) { | ||
component = getCSSForComponent(component, minify) | ||
@@ -32,0 +32,0 @@ const oldComponent = componentLibrary.global.findIndex((comp) => comp.name === component.name) |
{ | ||
"name": "astro-css-components", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"description": "CSS Components for Astro", | ||
@@ -25,3 +25,6 @@ "main": "index.js", | ||
}, | ||
"homepage": "https://github.com/Princesseuh/astro-css-components#readme" | ||
"homepage": "https://github.com/Princesseuh/astro-css-components#readme", | ||
"dependencies": { | ||
"csso": "^4.2.0" | ||
} | ||
} |
@@ -116,2 +116,12 @@ # astro-css-components | ||
#### minify | ||
By adding this props, the CSS will be minified through [csso](https://github.com/css/csso) | ||
**Example:** | ||
```jsx | ||
<CSSComponent minify register={{ name: "should-be-purple", content: ".should-be-purple {color: purple;}" }} /> | ||
``` | ||
### getForURL | ||
@@ -118,0 +128,0 @@ |
10
utils.js
import { readFileSync } from 'fs' | ||
import csso from 'csso' | ||
// If the user supplied a file instead of a string, let's load it up | ||
function getCSSForComponent(component) { | ||
function getCSSForComponent(component, minify) { | ||
if (!component.content && component.contentFile) { | ||
@@ -9,4 +10,11 @@ component.content = readFileSync(component.contentFile, "utf8") | ||
if (minify) component.content = minifyCSS(component.content) | ||
return { ...component } | ||
} | ||
function minifyCSS(css) { | ||
return csso.minify(css).css | ||
} | ||
export { getCSSForComponent } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7612
7
59
146
1
+ Addedcsso@^4.2.0
+ Addedcss-tree@1.1.3(transitive)
+ Addedcsso@4.2.0(transitive)
+ Addedmdn-data@2.0.14(transitive)
+ Addedsource-map@0.6.1(transitive)