Skip to content

Instantly share code, notes, and snippets.

View developit's full-sized avatar
🦊
write, the codes

Jason Miller developit

🦊
write, the codes
View GitHub Profile

cssnano-preset-simple

This is cssnano-preset-default, but without SVGO. It's a fraction of the size on disk if you're looking to avoid the 10mb footprint.

cssnano-preset-simple

This is cssnano-preset-default, but without SVGO. It's a fraction of the size on disk if you're looking to avoid the 10mb footprint.

optimize-css-assets-webpack-plugin-simple

It's literally the original plugin, just bundled up in a way that excludes SVGO. Instead of 10.6mb, it's 184kb and one file.

package-lock.json
node_modules
import { h, options } from 'preact';
const X = 'props' in h('a');
export const getProps = X ? vnode => vnode.props : vnode => vnode.attributes;
export const setProps = X
? (vnode, props) => { vnode.props = props; }
: (vnode, props) => { vnode.attributes = props; };
const Component = require('preact/compat').Component;
const AUTOBIND_BLACKLIST = {
constructor: 1,
render: 1,
shouldComponentUpdate: 1,
componentWillReceiveProps: 1,
componentWillUpdate: 1,
componentDidUpdate: 1,
componentWillMount: 1,

[native-url] webpack demonstration

Normal Build: 13.4 kB

With [native-url]: 5.95 kB

(less than half the size)

The result is functionally equivalent in Node 7+ and all modern browsers (Chrome 61+, Firefox 60+, Safari 10+, Edge 16+ and anything else with ES Modules support).

@developit
developit / *babel-plugin-dynamic-import-polyfill.md
Created November 12, 2019 19:57
babel-plugin-dynamic-import-polyfill
@developit
developit / esmodules-polyfill.js
Last active November 15, 2020 21:19
polyfill ES2018 standard library stuff for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)
if (!('trimStart' in String.prototype)) String.prototype.trimStart = String.prototype.trimLeft;
if (!('trimEnd' in String.prototype)) String.prototype.trimEnd = String.prototype.trimRight;
if (!('forEach' in NodeList.prototype)) NodeList.prototype.forEach = [].forEach;
if (!('description' in Symbol.prototype)) {
Object.defineProperty(Symbol.prototype, 'description', {
get() { return /\((.+)\)/.exec(this)[1] }
});
}
import regexparam from 'https://unpkg.com/regexparam@1/dist/regexparam.mjs';
/**
* <url-route href="/profile/:user">
* <div>some content here</div>
* </url-route>
*/
customElements.define('url-route', class UrlRoute extends HTMLElement {
connectedCallback() {
this.route = regexparam(this.getAttribute('href'));