Skip to content

Instantly share code, notes, and snippets.

View laruiss's full-sized avatar
🏠
Working from home

Stanislas Ormières laruiss

🏠
Working from home
View GitHub Profile
new SWPrecacheWebpackPlugin({
// By default, a cache-busting query parameter is appended to requests
// used to populate the caches, to ensure the responses are fresh.
// If a URL is already hashed by Webpack, then there is no concern
// about it being stale, and the cache-busting can be skipped.
dontCacheBustUrlsMatching: /\.\w{8}\./,
filename: 'service-worker.js',
logger(message) {
if (message.indexOf('Total precache size is') === 0) {
// This message occurs for every build and is a bit too noisy.
@laruiss
laruiss / .hyper.js
Last active May 6, 2018 10:55
hyperjs conf
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// Choose either "stable" for receiving highly polished,
// or "canary" for less polished but more frequent updates
updateChannel: 'stable',
@laruiss
laruiss / flex-obects.css
Last active August 25, 2019 14:44
BEM-, BEMIT-style flex object classes (CSSnext)
:root {
--mobile-max-width: 768px;
}
.o-flex {
display: flex;
&--wrap {
flex-wrap: wrap;
}
@laruiss
laruiss / index.js
Last active October 15, 2017 18:01
ESM file with import
import add from './add'
console.log(add(1, 2))
@laruiss
laruiss / add.js
Last active October 15, 2017 18:03
ESM file with ES2015 syntax and export
function add (a, b) {
return a + b
}
const sum = (...args) => args.reduce(add)
export default sum
@laruiss
laruiss / add.js
Created October 15, 2017 16:22
Simple ESM
function add (a, b) {
 return a + b
}
export default add
@laruiss
laruiss / add.js
Created October 15, 2017 16:20
Simple CommonJS module
function add (a, b) {
 return a + b
}
module.exports = add
@laruiss
laruiss / webpack.config.js
Last active October 15, 2017 16:19
Minimal Webpack config (Webpack post series)
module.exports = {
 entry: './src/index.js',
 output: {
 filename: 'build/bundle.js'
 }
}
# Install brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install wget
brew install wget
# Install Chrome
wget https://dl.google.com/chrome/mac/stable/GGRO/googlechrome.dmg
open googlechrome.dmg
@laruiss
laruiss / use-of-with-pkg.js
Last active October 15, 2017 18:05
with-pkg
var exit = require('exit')
var join = require('path').join
var fullPackagePath = join(process.cwd(), 'package.json')
var pkg = require(fullPackagePath)
const varsToInterpolate = process.argv.slice(2)
const vars = getInterpolations(varsToInterpolate)
function getInterpolations() {