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

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.

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.

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 September 6, 2019 16:47
glitch fix for components/text/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: '…' });
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>
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>

Temporarily bring back legacy VNode properties

Usage: just import the code from somewhere.

import './upgrade-polyfill';

lazy-loader

import lazyLoad from 'lazy-loader';

let mapPromise;
function getMap() {
  return mapPromise || (
 mapPromise = lazyLoad('/chunks/map.js', () =&gt; {

PreloadableWorker

There's no way to <link rel=preload> a Web Worker. This fixes that.

npm i -S gist:developit/567dde2346d785b2628224fddbf6783c

<!-- workers are now just a normal script preload: -->
<link rel=preload href=/path/to/worker.js as=script crossorigin>