【问题标题】:next-pwa is not working and there is no error in productionnext-pwa 不工作,生产中没有错误
【发布时间】:2021-11-21 04:48:15
【问题描述】:

repo 是开源的

// next.config.js
const withPWA = require("next-pwa");

module.exports = withPWA({
  pwa: {
    dest: "public",
    sw: '/sw.js'
  },
});

_document.js

_app.js

直播

https://time-stamp.vercel.app

我已经检查了 PWA 是否正在使用上述 URL 的天气

function isPwa() {
    return ["fullscreen", "standalone", "minimal-ui"].some(
        (displayMode) => window.matchMedia('(display-mode: ' + displayMode + ')').matches
    );
}
isPwa() // false
// https://stackoverflow.com/questions/41742390/javascript-to-check-if-pwa-or-mobile-web

【问题讨论】:

    标签: javascript next.js next-pwa


    【解决方案1】:

    您可能希望像这样使用next-pwa 包:

    const withPWA = require("next-pwa");
    const runtimeCaching = require("next-pwa/cache");
    
    module.exports = withPWA({
      pwa: {
        dest: "public",
        runtimeCaching,
        disable: process.env.NODE_ENV === "development",
      }
    });
    
    

    【讨论】:

    • 还是不行
    猜你喜欢
    • 2013-02-19
    • 2022-01-22
    • 2020-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-11
    • 2016-10-20
    • 2021-02-06
    相关资源
    最近更新 更多