如何在WorkboxPlugin.GenerateSW中忽略/排除CNAME记录

huangapple go评论53阅读模式
英文:

How to ignore/exclude CNAME record in WorkboxPlugin.GenerateSW

问题

I have a website and I deploy it using gh-pages. I've included the CNAME record in the build folder to point the GitHub page to my subdomain. When I use the WorkboxPlugin, it also includes the CNAME record. I'm unable to exclude the file.

new WorkboxPlugin.GenerateSW({
  clientsClaim: true,
  skipWaiting: true,
  exclude: [
    /\.map$/, // source maps
    /^manifest.*\.js(?:on)?$/, // web app manifest
  ],
}),
new CopyWebpackPlugin({
  patterns: [
    {
      from: path.join(__dirname, '../public/manifest.json'),
      to: path.join(__dirname, '../build/manifest.json'),
    },
    {
      from: path.join(__dirname, '../public/favicon.ico'),
      to: path.join(__dirname, '../build/'),
    },
    {
      from: path.join(__dirname, '../public/CNAME'),
      to({ context, absoluteFilename }) {
        return Promise.resolve('../build/[name]');
      },
    },
  ],
}),
英文:

I've a website and I deploy it using gh-pages. I've include the CNAME record in the build folder to point the GitHub page to my subdomain. When I use the WorkboxPlugin it also includes the CNAME record. I'm unable to exclude the file.

new WorkboxPlugin.GenerateSW({
  clientsClaim: true,
  skipWaiting: true,
  exclude: [
    /\.map$/, // source maps
    /^manifest.*\.js(?:on)?$/, // web app manifest
  ],
}),
new CopyWebpackPlugin({
  patterns: [
    {
      from: path.join(__dirname, '../public/manifest.json'),
      to: path.join(__dirname, '../build/manifest.json'),
    },
    {
      from: path.join(__dirname, '../public/favicon.ico'),
      to: path.join(__dirname, '../build/'),
    },
    {
      from: path.join(__dirname, '../public/CNAME'),
      to({ context, absoluteFilename }) {
        return Promise.resolve('../build/[name]');
      },
    },
  ],
}),

答案1

得分: 0

添加/CNAME/会排除CNAME记录。

英文:

Adding /CNAME/ excludes the CNAME record

new WorkboxPlugin.GenerateSW({
  clientsClaim: true,
  skipWaiting: true,
  exclude: [
   /\.map$/, // source maps
   /^manifest.*\.js(?:on)?$/, // web app manifest
   /CNAME/,
  ],
})

huangapple
  • 本文由 发表于 2023年5月10日 15:03:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/76215719.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定