首页 > 解决方案 > 如何使用资产路径自定义工作箱构建以进行预兑现

问题描述

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

我已经阅读了所有的dos,但还没有找到任何配置选项。

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"
  },```

标签: service-workercreate-react-appworkbox

解决方案


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


推荐阅读