Skip to content

Instantly share code, notes, and snippets.

@idudinov
idudinov / install-ext-deps.ts
Last active June 7, 2021 22:55
Firebase Functions: use outer npm package
/*
The idea of this script is to directly add some packages to Firebase [Functions] projects if they were used indirectly via parent node_modules.
Packages outlined in the `dependencies` array below will be installed as dependencies to `thisPackage`. Current versions (if any) of them will be stored in a `backup` file.
In `restore` mode the `backup` file created on the main usage mode will be used to restore packages initial version or remove them at all.
In an ideal word, after using this script in main and `restore` modes no file changes should left.
Usage:
yarn ts-node utils/install-ext-deps.ts
and for `restore` mode:
yarn ts-node utils/install-ext-deps.ts --restore
@idudinov
idudinov / babel.config.js
Created September 20, 2019 10:47
Expo & webpack compatible Environment configuration
// Babel config that can be used in Expo
const appConfig = require('../config.js');
const envConfig = appConfig.generateVariables('.env', './package.json', true);
module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
@idudinov
idudinov / prerenderPlugin.js
Last active June 16, 2021 14:56
PrerenderPlugin for HtmlWebpackPlugin – Pre-renders html during Webpack build phase
const HtmlWebpackPlugin = require('html-webpack-plugin');
const jsdom = require('jsdom');
/** @typedef {import("webpack/lib/Compiler.js")} WebpackCompiler */
/** @typedef {import("webpack/lib/Compilation.js")} WebpackCompilation */
/** @typedef {(import 'jsdom').ResourceLoaderConstructorOptions} ResourceLoaderConstructorOptions */
class PrerenderHtmlPlugin {
constructor(options) {
this._options = options || { };