Skip to content

Instantly share code, notes, and snippets.

View kevinah95's full-sized avatar
🇨🇷

Kevin Hernández Rostrán kevinah95

🇨🇷
View GitHub Profile
@kevinah95
kevinah95 / config-overrides.js
Created August 7, 2018 00:35
config-overrides.js v2 for Using Workbox with Create React App (Without Ejecting) Medium
const workboxConfig = {
...defaultInjectConfig,
swSrc: path.join(__dirname, "src", "custom-sw.js"),
importWorkboxFrom: "local" // Add this propertie
};
@kevinah95
kevinah95 / registerServiceWorker.js
Created August 7, 2018 00:21
registerServiceWorker.js for Using Workbox with Create React App (Without Ejecting) Medium
export default function register() {
// Some validations here
window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/custom-sw.js`; // In this line
...
}
// Another stuffs here
}
@kevinah95
kevinah95 / custom-sw.js
Created August 7, 2018 00:11
custom-sw.js for Using Workbox with Create React App (Without Ejecting) Medium
// See https://developers.google.com/web/tools/workbox/guides/configure-workbox
workbox.core.setLogLevel(workbox.core.LOG_LEVELS.debug);
self.addEventListener('install', event => event.waitUntil(self.skipWaiting()));
self.addEventListener('activate', event => event.waitUntil(self.clients.claim()));
// We need this in Webpack plugin (refer to swSrc option): https://developers.google.com/web/tools/workbox/modules/workbox-webpack-plugin#full_injectmanifest_config
workbox.precaching.precacheAndRoute(self.__precacheManifest);
@kevinah95
kevinah95 / package.json
Last active August 7, 2018 00:45
package.json for Using Workbox with Create React App (Without Ejecting) Medium
{
...
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test --env=jsdom",
},
...
}
@kevinah95
kevinah95 / config-overrides.js
Last active August 7, 2018 00:06
config-overrides.js for Using Workbox with Create React App (Without Ejecting) Medium
const {rewireWorkboxInject, defaultInjectConfig} = require('react-app-rewire-workbox');
const path = require('path');
module.exports = function override(config, env) {
if (env === "production") {
console.log("Production build - Adding Workbox for PWAs");
// Extend the default injection config with required swSrc
const workboxConfig = {
...defaultInjectConfig,
swSrc: path.join(__dirname, 'src', 'custom-sw.js')
@kevinah95
kevinah95 / .prettierrc
Last active July 23, 2018 02:02
Prettier React
//REF: https://medium.com/technical-credit/using-prettier-with-vs-code-and-create-react-app-67c2449b9d08
//Options: https://prettier.io/docs/en/options.html
{
"singleQuote": true,
"trailingComma": "es5",
"semi": false
}
@kevinah95
kevinah95 / Readme.md
Created July 18, 2018 04:29
Web Security

HTTPS

Una extensión cifrada del protocolo HTTP tradicional. Para realizar este cifrado, cada conexión con HTTP se envía sobre una capa SSL o TLS. El objetivo de usar HTTPS responde a dos cuestiones:

  • Certificar que la web visitada es legítima
  • Se mantiene la integridad y la privacidad de los datos de conexión.
@kevinah95
kevinah95 / index-pwa.html
Last active June 6, 2018 19:04 — forked from ianaya89/favicons.html
[PWA] All Favicons for All Devices and Sizes
<!-- manifest -->
<link rel="manifest" href="manifest.json">
<!-- favicon -->
<link rel="shortcut icon" sizes="16x16 32x32 48x48 64x64" href="favicon.ico">
<!-- iOS -->
<link rel="apple-touch-icon" href="touch-icon-iphone.png">
<link rel="apple-touch-icon" sizes="152x152" href="touch-icon-ipad.png">
<link rel="apple-touch-icon" sizes="180x180" href="touch-icon-iphone-retina.png">
@kevinah95
kevinah95 / gist:65f0fc16a80948eeb8881b71d95dfed0
Created October 9, 2017 02:03 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream