Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Modular CSS bundler for browserify. Works with npm modules like browserify does.
Given some inline CSS:
const vdom = require('virtual-dom')
const hyperx = require('hyperx')
const sf = require('sheetify')
const hx = hyperx(vdom.h)
const prefix = sf`
h1 {
text-align: center;
}
`
const tree = hx`
<section className=${prefix}>
<h1>My beautiful, centered title</h1>
</section>
`
document.body.appendChild(vdom.create(tree))
Compile with browserify using -t sheetify/transform
:
$ browserify -t sheetify/transform index.js > bundle.js
CSS classes are namespaced based on the content hash:
._60ed23ec9f h1 {
text-align: center;
}
And the rendered HTML includes the namespace:
<section class="._60ed23e">
<h1>My beautiful, centered title</h1>
</section>
To include an external CSS file you can pass a path to sheetify as
sheetify('./my-file.css')
:
const vdom = require('virtual-dom')
const hyperx = require('hyperx')
const sf = require('sheetify')
const hx = hyperx(vdom.h)
const prefix = sf('./my-styles.css')
const tree = hx`
<section className=${prefix}>
<h1>My beautiful, centered title</h1>
</section>
`
document.body.appendChild(vdom.create(tree))
To consume a package from npm that has .css
file in its main
or style
field:
const sf = require('sheetify')
sf('css-wipe')
Packages from npm will not be namespaced by default.
To toggle namespaces for external files or npm packages:
const sf = require('sheetify')
sf('./my-file.css', { global: true })
To write the compiled CSS to a separate file, rather than keep it in the bundle:
$ browserify -t [ sheetify/transform -o bundle.css ] index.js > bundle.js
To write the compiled CSS to a stream:
const browserify = require('browserify')
const fs = require('fs')
const b = browserify(path.join(__dirname, 'transform/source.js'))
const ws = fs.createWriteStream('/bundle.css')
b.transform('sheetify', { out: ws })
const r = b.bundle().pipe(fs.createWriteStream('./bundle.js'))
r.on('end', () => ws.end())
Browserify transforms don't know when browserify
is done, so we have to
attach a listener on browserify for the 'end'
event to close the writeStream
accordingly.
Sheetify uses plugins that take CSS and apply a transform. For example include sheetify-cssnext to support autoprefixing, variables and more:
const vdom = require('virtual-dom')
const hyperx = require('hyperx')
const sf = require('sheetify')
const hx = hyperx(vdom.h)
const prefix = sf`
h1 {
transform: translate(0, 0);
}
`
const tree = hx`
<section className=${prefix}>
<h1>My beautiful, centered title</h1>
</section>
`
document.body.appendChild(vdom.create(tree))
Compile with browserify using -t [ sheetify/transform -u sheetify-cssnext ]
:
$ browserify -t [ sheetify/transform -u sheetify-cssnext ] index.js > bundle.js
Transforms the CSS into:
h1 {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
The following plugins are available:
Browserify transforms accept either flags from the command line using subargs:
$ browserify -t [ sheetify/transform -o bundle.css ] index.js > bundle.js
Or the equivalent options by passing in a configuration object in the JavaScript API:
const browserify = require('browserify')
const b = browserify(path.join(__dirname, 'transform/source.js'))
b.transform('sheetify', { out: path.join(__dirname, '/bundle.css') })
b.bundle().pipe(process.stdout)
The following options are available:
Options:
-o, --out Specify an output file
-u, --use Consume a sheetify plugin
$ npm install sheetify
FAQs
Modular CSS bundler
The npm package sheetify receives a total of 124 weekly downloads. As such, sheetify popularity was classified as not popular.
We found that sheetify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.