Skip to content

Instantly share code, notes, and snippets.

View gcangussu's full-sized avatar

Gabriel Cangussu gcangussu

  • Belo Horizonte, Brazil
View GitHub Profile
@gcangussu
gcangussu / webpack.config.js
Created September 21, 2018 15:01
Webpack Setup
const path = require('path');
const history = require('connect-history-api-fallback');
const convert = require('koa-connect');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
@gcangussu
gcangussu / tsconfig.json
Created September 21, 2018 15:04
Typescript compiler setup for front end
{
"compilerOptions": {
/* Basic Options */
"target": "es2018",
"module": "es2015",
"resolveJsonModule": false, // Don't use untill fixed: https://github.com/Microsoft/TypeScript/issues/26020
"lib": ["dom", "esnext"],
"allowJs": false,
"jsx": "preserve",
"sourceMap": true,
@gcangussu
gcangussu / babel.config.js
Created September 21, 2018 15:05
Babel config for front end
const isProduction = process.env.NODE_ENV === 'production';
const isTest = process.env.NODE_ENV === 'test';
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
chrome: '65',
@gcangussu
gcangussu / tsconfig.json
Last active September 23, 2018 18:38
Typescript setup for back end
{
"compilerOptions": {
/* Basic Options */
"target": "es2018", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"lib": ["es2018"], /* Specify library files to be included in the compilation. */
"resolveJsonModule": true,
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
@gcangussu
gcangussu / .eslintignore
Last active September 23, 2018 18:43
Eslint front end setup
coverage
build
dist
@gcangussu
gcangussu / render_with_wb.js
Created December 10, 2020 17:52
Avoid blinking on first visit with service worker
/*
* When we have a workbox we must be sure to just render the
* app when we assert that we are running the latest version.
* Otherwise the user can start interacting with the app and
* right after an update arrives and the page is reloaded.
*/
if (wb != null) {
wb.active
.then((serviceWorker) => {
/* When the service worker active is not controlling the
@gcangussu
gcangussu / factories.ts
Last active March 24, 2021 21:42
Mock /loan/rfqs/ endpoint on frontend. You need to change two files.
// packages/utils/tests/factories.ts
// import { createHash } from 'crypto';
import faker from 'faker';
/**
* Seed the random sequence that generates the random values.
* @param sentence Any string to use as seed
*/
export function seed(sentence: string) {
@gcangussu
gcangussu / removeRequirePaths.js
Created March 2, 2020 02:30
Prevent Node.js require looking for node_modules in parent directories. Usefull for isolating your project against node_modules directories upward in the file hierarchy.
// Put this on the top of your entry file or use Node's `-r` cli option
const { Module } = require("module");
const originalResolveLookupPaths = Module._resolveLookupPaths;
Module._resolveLookupPaths = function(request, parent) {
const paths = originalResolveLookupPaths.call(Module, request, parent);
if (request.startsWith(".")) return paths;
@gcangussu
gcangussu / jest-resolver.js
Last active October 31, 2023 15:06
Custom Jest resolver to preserve symlinks. Useful for usage with Bazel. Requires `resolve` npm package.
const resolve = require('resolve');
/**
* @typedef {{
basedir: string;
browser?: boolean;
defaultResolver: (request: string, options: ResolverOptions) => string;
extensions?: readonly string[];
moduleDirectory?: readonly string[];
paths?: readonly string[];