Skip to content

Instantly share code, notes, and snippets.

View evenstensberg's full-sized avatar
🐪

Even Stensberg evenstensberg

🐪
View GitHub Profile
@evenstensberg
evenstensberg / webpack.config.js
Created April 22, 2020 13:39
Example webpack configuration
const path = require("path");
const webpack = require("webpack");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const isDev = true;
const isHmr = process.env.NODE_ENV === "hmr";
module.exports = {
devtool: "inline-source-map",
@evenstensberg
evenstensberg / webpack.config.js
Last active April 3, 2020 16:42
Example Chunk Splitting Strategy
module.exports = {
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
name: 'vendor',
test: /[\\/]node_modules[\\/]/,
chunks: 'all',
maxSize: 500000
},
@evenstensberg
evenstensberg / test.js
Created May 29, 2019 09:10
Run from root in webpack-cli, this is the behaviour of merge prop atm
const yoConfig = {
"webpack-cli": {
"configuration": {
"config": {
"merge": "okay",
"topScope": [
"const webpack = require('webpack')",
"const path = require('path')",
"\n",
"/*\n * SplitChunksPlugin is enabled by default and replaced\n * deprecated CommonsChunkPlugin. It automatically identifies modules which\n * should be splitted of chunk by heuristics using module duplication count and\n * module category (i. e. node_modules). And splits the chunks…\n *\n * It is safe to remove \"splitChunks\" from the generated configuration\n * and was added as an educational example.\n *\n * https://webpack.js.org/plugins/split-chunks-plugin/\n *\n */",

What kind of sound does a mathematical bird make?

𝝅*p

@evenstensberg
evenstensberg / perf.sh
Created February 25, 2018 15:04
ESM perf on test suite
#!/usr/bin/env bash
T="$(date +%s)"
cd esm
npm run test
T="$(($(date +%s)-T))"
npm install --save v8-compile-cache
ex -sc '2i|require("v8-compile-cache")' -cx script/test.js
T2="$(date +%s)"
@evenstensberg
evenstensberg / work.md
Last active January 7, 2018 20:15
Start your day right

Work

This script helps you start your development by opening your project in vscode, its github repository and optionally slack.

Usage

work react

Installation

@evenstensberg
evenstensberg / smoketest.bash
Created January 6, 2018 12:20
Smoketest for karma bug reproduction
# Get outer pID so we can exit it later
trap "exit 9" TERM
TOP_PID=$$
# Get pID of chrome (requires you to have pidof on your computer)
# http://brewformulas.org/Pidof
PidName=`pidof chrome`
found=false
var path = require('path');
var webpack = require('webpack');
module.exports = {
devtool: 'eval',
entry: [
'./src/index'
],
output: {
path: path.join(__dirname, 'dist'),
var path = require('path');
var webpack = require('webpack');
module.exports = {
devtool: 'eval',
entry: [
'./src/index'
],
output: {
path: path.join(__dirname, 'dist'),

Testing output

Paste this somewhere in a generator
this.configuration.webpackOptions.entry = {
vendor: 'home',
js: 'yes',
ohye: 'no'
};