hanford / next-offline

make your Next.js application work offline using service workers via Google's workbox
https://github.com/hanford/next-offline
1.59k stars 111 forks source link

Getting warnings while yarn build #217

Closed rahul3103 closed 1 year ago

rahul3103 commented 4 years ago

Getting warnings while yarn build

Compiled with warnings.

You're using the following Workbox configuration options: [globDirectory, globPatterns]. In Workbox v3 and later, this is usually not needed. Please see https://goo.gl/EQ4Rhm for more info.

One of the glob patterns doesn't match any files. Please remove or fix the following: {
  "globDirectory": ".",
  "globPattern": "static/**/*",
  "globIgnores": [
    "**/node_modules/**/*"
  ]
}

In the case of a bug report 🐞

/* eslint-disable no-console */
const dotEnvResult = require('dotenv').config();
const {
  PHASE_DEVELOPMENT_SERVER,
  PHASE_PRODUCTION_SERVER,
  PHASE_PRODUCTION_BUILD
} = require('next/constants');
const withOffline = require('next-offline');

if (dotEnvResult.error) {
  throw dotEnvResult.error;
}

const parsedVariables = dotEnvResult.parsed || {};

const withBundleAnalyzer = require('@next/bundle-analyzer')({
  enabled: process.env.ANALYZE === 'true'
});

const nextConfig = phase => {
  const isDev = phase === PHASE_DEVELOPMENT_SERVER;
  const isProd = phase === PHASE_PRODUCTION_SERVER;
  const isProdBuild = phase === PHASE_PRODUCTION_BUILD;

  return {
    analyzeServer: ['server', 'both'].includes(process.env.BUNDLE_ANALYZE),
    analyzeBrowser: ['browser', 'both'].includes(process.env.BUNDLE_ANALYZE),
    bundleAnalyzerConfig: {
      server: {
        analyzerMode: 'static',
        reportFilename: '../bundles/server.html'
      },
      browser: {
        analyzerMode: 'static',
        reportFilename: '../bundles/client.html'
      }
    },
    env: {
      isDev,
      isProd,
      isProdBuild,
      BACKEND_URL: parsedVariables.API_HOST,
    },
    webpack(config) {
      return config;
    }
  };
};

module.exports = phase => withBundleAnalyzer(withOffline(nextConfig(phase)));
bluelovers commented 4 years ago

same here and

SW registration failed:  TypeError: Failed to register a ServiceWorker for scope ('https://xxx.now.sh/') with script ('https://xxx.now.sh/service-worker.js'): A bad HTTP response code (404) was received when fetching the script.