Skip to content

Instantly share code, notes, and snippets.

View ChristianRV29's full-sized avatar
:electron:
Programming

Christian Riaño ChristianRV29

:electron:
Programming
  • NWYC
  • Sogamoso, Colombia
  • 21:12 (UTC -05:00)
View GitHub Profile
@ChristianRV29
ChristianRV29 / sw.ts
Created February 21, 2025 20:08
Service worker of PWA
import { cleanupOutdatedCaches, precacheAndRoute } from 'workbox-precaching'
import { registerRoute } from 'workbox-routing'
import { NetworkFirst } from 'workbox-strategies'
declare const self: ServiceWorkerGlobalScope
cleanupOutdatedCaches()
precacheAndRoute(self.__WB_MANIFEST)
@ChristianRV29
ChristianRV29 / vite.config.ts
Last active February 21, 2025 20:07
React TS + Vite: Configuration of a PWA
import { VitePWA } from 'vite-plugin-pwa'
// Run command `npx pwa-asset-generator public/todo-image.png public` to generate assets automatically
VitePWA({
// Allows to service worker auto updates
registerType: 'autoUpdate',
// Allows run service worker in dev mode
devOptions: {
enabled: true,
@ChristianRV29
ChristianRV29 / Typography.tsx
Last active March 14, 2024 20:54
Reusable component for the management of dynamic fonts. (Tailwind CSS)
import { FC, ReactNode } from 'react'
type Variant = 'title' | 'overline' | 'paragraph' | 'button'
interface Props {
children: ReactNode
color?: keyof typeof colors
tag: keyof JSX.IntrinsicElements
variant: Variant
}

React via CDN

For loading ReactJS through CDN we'll need to include these scripts in our html head

  <script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
  <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
  <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>