Skip to content

Instantly share code, notes, and snippets.

View Akash52's full-sized avatar
🐢
Focusing

Akash Chauhan Akash52

🐢
Focusing
View GitHub Profile
Getting and Creating Projects
@Akash52
Akash52 / manifest.json
Created May 20, 2023 07:02
manifest.jons file for PWA
{
"name": "angular-rental-app",
"short_name": "angular-rental-app",
"theme_color": "#1976d2",
"background_color": "#fafafa",
"display": "standalone",
"scope": "./",
"start_url": "./",
"icons": [
{
@Akash52
Akash52 / vite.config.js
Last active May 29, 2023 17:17
Vite PWA Configuration for the Vue 3
import { fileURLToPath, URL } from "node:url";
import { VitePWA } from "vite-plugin-pwa";
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
VitePWA({
registerType: "autoUpdate",
{
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
"index": "/index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/favicon.ico",
@Akash52
Akash52 / serviceworker.js
Last active May 30, 2023 20:39
serviceworker.js file for react
//This is a service worker script that caches specific URLs for offline use and handles network requests when the internet connection is not available.
// We give a name to our cache, so we can refer to it later.
const CACHE_NAME = "version-1";
// These are the URLs that we want to cache.
const urlsToCache = ["index.html", "offline.html"];
// We call the 'self' object, which refers to the Service Worker itself.
const self = this;
@Akash52
Akash52 / index.html
Created May 28, 2023 09:32
index.html for react
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Rentals App" />
<meta name="author" content="Rental App" />
<meta name="keywords" content="rental, app, rentals app" />
@Akash52
Akash52 / serviceworker.js
Created May 28, 2023 09:38
serviceworker.js for svelte
import { build, files } from '$service-worker';
const worker = self;
const STATIC_CACHE_NAME = 'cache-v1';
const APP_CACHE_NAME = 'offline-v1';
const CACHE_NAMES = [STATIC_CACHE_NAME, APP_CACHE_NAME];
const version = 'v1';
// hard-coded list of app routes we want to preemptively cache
const routes = ['/'];
@Akash52
Akash52 / app.html
Created May 28, 2023 09:42
app.html for svelte
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Rentals App" />
<meta name="author" content="Rental App" />
<meta name="keywords" content="rental, app, rentals app" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
@Akash52
Akash52 / manifest.js
Created May 28, 2023 09:50
manifest.json for all the tech
{
"name": "application name", // sets the name of the app
"short_name": "short name application", // sets a shorter name of the app
"theme_color": "#1976d2", // determines the primary color scheme used by the app
"background_color": "#fafafa", // sets the background color behind the app when it is launched
"display": "standalone", // determines how the app is displayed to users
"scope": "./", // specifies the base URL for the app and restricts its access to specific folders
"start_url": "./", // specifies the URL where the app should start when launched from the user's home screen or app launcher
"icons": [ // contains an array of objects specifying the icons used for the app
{
@Akash52
Akash52 / next.config.js
Last active May 31, 2023 18:36
next.config.js for Next.js
/** @type {import('next').NextConfig} */
const withPWA = require("next-pwa")({
dest: "public", // output directory
register: true, // register pwa
skipWaiting: true, // skip waiting for old service worker to be disabled
disable: process.env.NODE_ENV === "development", // disable in development
runtimeCaching: [
//cache assets & data from external api
{