Skip to content

Instantly share code, notes, and snippets.

Avatar
🥰
what's up?

Even Stensberg evenstensberg

🥰
what's up?
View GitHub Profile
@evenstensberg
evenstensberg / webpack.config.js
Created Apr 22, 2020
Example webpack configuration
View webpack.config.js
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 Apr 3, 2020
Example Chunk Splitting Strategy
View webpack.config.js
module.exports = {
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
name: 'vendor',
test: /[\\/]node_modules[\\/]/,
chunks: 'all',
maxSize: 500000
},
@evenstensberg
evenstensberg / test.js
Created May 29, 2019
Run from root in webpack-cli, this is the behaviour of merge prop atm
View test.js
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 */",
@evenstensberg
evenstensberg / perf.sh
Created Feb 25, 2018
ESM perf on test suite
View perf.sh
#!/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 Jan 7, 2018
Start your day right
View work.md

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 Jan 6, 2018
Smoketest for karma bug reproduction
View smoketest.bash
# 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
View webpack.before.config.js
var path = require('path');
var webpack = require('webpack');
module.exports = {
devtool: 'eval',
entry: [
'./src/index'
],
output: {
path: path.join(__dirname, 'dist'),
View webpack.after.config.js
var path = require('path');
var webpack = require('webpack');
module.exports = {
devtool: 'eval',
entry: [
'./src/index'
],
output: {
path: path.join(__dirname, 'dist'),
View test.md

Testing output

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

What kind of sound does a mathematical bird make?

𝝅*p