@Sergefront

Как исправить ошибку устаревших файлов vue js?

есть проблема во vue js проекте, через некоторое время если не заходить на сайт то в консоли вылазит ошибка

Refused to execute script from 'https://site/js/chunk-vendors.256a3953.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
Refused to execute script from 'https://site/js/app.017c15c6.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.


я так понял что проблема связанна с кэшем но нужна помощь решить проблему.
Вот содержимое файла vue.config.js
module.exports = {
    pwa: {
        name: 'Dialllog',
        themeColor: '#246690',
        msTileColor: '#FFFFFF',
        appleMobileWebAppCapable: 'no',
        appleMobileWebAppStatusBarStyle: 'default',
        workboxOptions: {
            skipWaiting: true,
            clientClaim: true,
            navigateFallback: 'index.html',
          	navigateFallbackDenylist: [/api*/],
        },
    },
    chainWebpack: config => {
      config.plugins.delete('prefetch');
      config.plugins.delete('prefetch-index');
      config.plugin('define').tap((definitions) => {
        Object.assign(definitions[0], {
          __VUE_OPTIONS_API__: 'true',
          __VUE_PROD_DEVTOOLS__: 'false',
          __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false'
        })
        return definitions
      })
    },
    configureWebpack: {
        resolve: {
          fallback: {
            "path": require.resolve("path-browserify")
          }
        }
    }
}


а вот содержимое файла registerServiceWorker.js:
/* eslint-disable no-console */

import { register } from "register-service-worker";

if (process.env.NODE_ENV === "production") {
  
  register(`${process.env.BASE_URL}service-worker.js`, {
    ready() {
      console.log("Content has been cached for offline use.");(
          "App is being served from cache by a service worker.\n" +
          "For more details, visit https://goo.gl/AFskqB"
      );
    },
    registered(registration) {
      console.log("Service worker has been registered.");
      setInterval(() => {
        registration.update();
      }, 1000 * 300);
    },
    cached() {
      console.log("Content has been cached for offline use.");
    },
    updatefound() {
      caches.keys().then(cacheNames => {
        cacheNames.forEach(cacheName => {
          caches.delete(cacheName);
        });
      });
      console.log("New content is downloading.");
    },
    updated(registration) {
      console.log('New content is available; please refresh.');
      setTimeout(() => {
        window.location.reload(true)
      }, 1000)
      // document.dispatchEvent(
      //     new CustomEvent('serviceWorkerUpdateEvent', { detail: registration })
      // );
    },
    offline() {
      console.log(
          "No internet connection found. App is running in offline mode."
      );
    },
    error(error) {
      console.error("Error during service worker registration:", error);
    },
  });
}

может ли быть проблема в сервис воркере? и какие правки стоит внести в эти файлы чтоб исправить ошибки с устаревшими файлами?
  • Вопрос задан
  • 72 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы