如何定制工作箱构建以及用于预兑现的资产路径

问题描述 投票:0回答:1

我正在设置用于生成服务工作器的自定义配置。我正在使用injectManifest。问题是我的资产已部署到具有与应用程序运行不同的域的s3存储桶。

我已经阅读了所有文档,但尚未找到任何配置选项。

const buildSW = () => {
    // This will return a Promise
    return workboxBuild
        .injectManifest({
            swSrc: 'src/sw-template.js',
            swDest: 'build/sw.js', // this will be created in the build step
            globDirectory: 'build',
            globPatterns: ['**\/*.{js, html}'],
        })
        .then(({ count, size, warnings }) => {
            // Optionally, log any warnings and details.
            warnings.forEach(console.warn);
            console.log(`${count} files will be precached, totaling ${size} bytes.`);
        });
};
buildSW();

我收到类似的配置:

    "url": "static/js/runtime~main.ccae3505.js",
    "revision": "51731239672d142923190a6cfb73ce8b"
  },

但是想要类似的东西>

    "url": "https://myCustomDomain.com/static/js/runtime~main.ccae3505.js",
    "revision": "51731239672d142923190a6cfb73ce8b"
  },```

我正在设置用于生成服务工作器的自定义配置。我正在使用injectManifest。问题是我的资产已部署到具有与应用程序运行不同的域的s3存储桶。我读过...

service-worker create-react-app workbox
1个回答
0
投票

我发现了它-希望它对某人有用:manifestTransforms可以解决问题

© www.soinside.com 2019 - 2024. All rights reserved.