Skip to content

Instantly share code, notes, and snippets.

🦊
write, the codes

Jason Miller developit

🦊
write, the codes
Block or report user

Report or block developit

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View preact-lib-utils.js
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; };
View .gitignore
package-lock.json
node_modules
View *optimize-css-assets-webpack-plugin-simple.md

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.

View *cssnano-preset-simple.md

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.

View *cssnano-preset-simple.md

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.

View *babel-plugin-import-cdn.md

Combines all bare imports (npm module imports) into a single packd-es import.

Input:

import { h, render } from 'preact@next';
import { useState } from 'preact@next/hooks';
import { html } from 'htm/preact';
render(h(() => html`<a />`), document.body);
@developit
developit / markdown.js
Last active Sep 6, 2019
glitch fix for components/text/markdown.js
View markdown.js
/**
* Markdown Component
*/
const Markdown = React.memo(({ children, length, allowImages, renderAsPlaintext, linkifyHeadings }) => {
let rendered = md({ allowImages, linkifyHeadings }).render(children || '');
let className = styles.markdownContent;
if (length > 0) {
rendered = truncate(rendered, length, { ellipsis: '' });
View htm-ssr-direct.js
const express = require('express');
const htm = require('htm');
const vhtml = require('vhtml');
// create an html`` tag function for vhtml:
const html = htm.bind(vhtml);
const App = (props) => html`
<div class="app">
<h1>This is an app</h1>
View htm-ssr.js
const express = require('express');
const { html, Component } = require('htm/preact');
const renderToString = require('preact-render-to-string');
class App extends Component {
render(props) {
return html`
<div class="app">
<h1>This is an app</h1>
<p>Current server time: ${new Date + ''}</p>
View preact 8 to 10 polyfill.md

Temporarily bring back legacy VNode properties

Usage: just import the code from somewhere.

import './upgrade-polyfill';
You can’t perform that action at this time.