Skip to content

Instantly share code, notes, and snippets.

@Akash52
Created May 30, 2023 20:32
Show Gist options
  • Save Akash52/5f74b58f5e2db915e8b9f5193c2142b3 to your computer and use it in GitHub Desktop.
Save Akash52/5f74b58f5e2db915e8b9f5193c2142b3 to your computer and use it in GitHub Desktop.
nuxt.config.js for nuxtJS
pwa: {
manifest: {
// Define basic app information
name: "Rentals Nuxt App", // Name of the app
short_name: "Rentals App", // Short name of the app
description: "Rentals App built with Nuxt.js", // Description of the app
theme_color: "#3b82f6", // Theme color of the app
lang: "en", // Language of the app
background_color: "#3b82f6", // Background color of the app
},
icon: {
// Define icon sizes
sizes: [64, 120, 144, 152, 192, 384, 512], // Size of the icon
},
meta: {
// Include additional metadata
name: "Rentals Nuxt App", // Name of the app
description: "Rentals App built with Nuxt.js", // Description of the app
author: "Vue Dev", // Author of the app
theme_color: "#3b82f6", // Theme color of the app
nativeUi: true, // Enable native UI settings for iOS
appleStatusBarStyle: "black", // Set status bar style for iOS
mobileAppIOS: true, // Indicate that the app is for iOS devices
},
// Configure offline caching using Workbox library
workbox: {
offline: true, // Enable offline caching
runtimeCaching: [
// Cache assets
{
urlPattern: /\.(?:png|gif|jpg|jpeg|svg|css|js)$/, // Match file extensions
handler: "cacheFirst", // Cache first, then network fallback
options: {
cacheName: "assets-cache", // Name the cache for assets
expiration: {
maxEntries: 50, // Maximum number of entries in the cache
maxAgeSeconds: 30 * 24 * 60 * 60, // Cache assets for 30 days
},
},
},
// Cache API calls
{
urlPattern: "https://mock-json-server-39aq.onrender.com/rentals", // Match API endpoint
handler: "networkFirst", // Fetch from network first, then cache fallback
options: {
cacheName: "api-cache", // Name the cache for API responses
expiration: {
maxEntries: 50, // Maximum number of entries in the cache
maxAgeSeconds: 60 * 60, // Cache API responses for 1 hour
},
},
},
],
},
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment