Skip to content

Instantly share code, notes, and snippets.

@nerdcave
nerdcave / environment.js
Last active May 11, 2021 12:27
PurgeCSS config for Rails 5 and Webpacker (along with Tailwind CSS and Vue.js, in this case)
// first run:
// yarn add glob-all purgecss-webpack-plugin --dev
/*
config/webpack/environment.js
PurgeCSS configuration for Rails 5 + Webpacker + Tailwind CSS + Vue.js
Optionally, put this in production.js if you only want this to apply to production.
For example, your app is large and you want to optimize dev compilation speed.
*/
@nerdcave
nerdcave / vue-test-slots.js
Created March 1, 2018 16:39
"Duplicate presence of slot" warning with trigger 'click' leveled/nested slots and vue-test-utils
// Jasmine v2.7
import {mount} from '@vue/test-utils/dist/vue-test-utils';
const Parent = {
name: 'Parent',
template: `
<Child>
<template slot-scope="props">
<slot name="content"></slot>
@nerdcave
nerdcave / js-test-lazy-evaluate.js
Last active February 22, 2018 20:52
JavaScript testing with lazy loading/evaluation (like Rspec let)
// Uses Jasmine's `this` feature:
// https://jasmine.github.io/2.9/introduction#section-The_<code>this</code>_keyword
// Example without lazy evaluation:
const sum = (a, b) => a + b;
describe('No lazy eval :(', () => {
let a, b, total;