Skip to content

Instantly share code, notes, and snippets.

View fivethreeo's full-sized avatar

Øyvind Saltvik fivethreeo

  • Levanger, Norway
View GitHub Profile
'use strict';
const path = require('path');
const fs = require('fs');
const appDirectory = fs.realpathSync(process.cwd());
const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
module.exports = {
modify: (defaultConfig, { target, dev }, webpack) => {
@fivethreeo
fivethreeo / razzle.config.js
Last active May 18, 2020 22:09
add a webpack module to razzle.config.js
'use strict';
module.exports = {
modify: (defaultConfig, { target, dev }, webpack) => {
const config = Object.assign({}, defaultConfig);
config.module.rules = config.module.rules.reduce((rules, rule) => {
if (rule.exclude &&
rule.loader.indexOf('file-loader') !== -1) {
location ^~ /myapp/ {
proxy_pass http://0.0.0.0:3001/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
sudo gawk -i inplace '{
if ($0 ~ /debian\.org|nodesource\.com|docker\.com/) {
print gensub(/buster/, "bullseye", "g")
} else {
print $0
}
}' /etc/apt/sources.list /etc/apt/sources.list.d/*.list
export MOUNT_DEV=/dev/sda1
export MOUNT_POINT=/mnt
sudo -E mount $MOUNT_DEV $MOUNT_POINT
sudo -E mount --bind /dev $MOUNT_POINT/dev
sudo -E mount --bind /proc $MOUNT_POINT/proc
sudo -E mount --bind /run $MOUNT_POINT/run
sudo -E mount --bind /sys $MOUNT_POINT/sys
sudo -E chroot $MOUNT_POINT
addWorkspaces:(stageName) => {
const stagePath = path.join(rootDir, stageName);
const packagesPath = path.join(rootDir, 'packages');
const packageJson = path.join(stagePath, 'package.json');
if (fs.existsSync(packageJson)) {
const dirs = fs.readdirSync(packagesPath, { withFileTypes:true })
.filter(dirent=>dirent.isDirectory()).map(dir=>dir.name);
let workspaces = [];
let packages = [];
@fivethreeo
fivethreeo / web.config
Last active December 17, 2020 23:42
Razzle deployment to Azure
<?xml version="1.0" encoding="utf-8"?>
<!--
This configuration file is required if iisnode is used to run node processes behind
IIS or IIS Express. For more information, visit:
https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config
-->
<configuration>
<system.webServer>
/**
* The passed list of environment variables will be removed from the nodejs
* instance of webpack.DefinePlugin, so they can be resolved dynamically at
* runtime.
* @example
* // Include this in the plugins array exported by razzle.config.js
* const nodeRuntimeVarsPlugin = createRazzlePluginNodeRuntimeVars('PORT', 'HOST');
* @param {String} ...nodeRuntimeVars
* @return {Function}
tests for isomorphic examples
tests for the basic example
✓ should install packages (17243 ms)
✓ should build successfully (4276 ms)
✓ should start devserver and exit (3275 ms)
tests for the basic-spa example
✓ should install packages (17225 ms)
✓ should build successfully (3311 ms)
✓ should start devserver and exit (2690 ms)
tests for the with-custom-babel-config example
<html><head><meta charset="utf-8"/><title>Examples Test Report</title><style type="text/css">html,
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 1rem;
margin: 0;
padding: 0;
color: #333;
}
body {
padding: 2rem 1rem;