webpackworkbox-webpack-plugin

How to ignore/exclude CNAME record in WorkboxPlugin.GenerateSW


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]');
      },
    },
  ],
}),

Solution

  • Adding /CNAME/ excludes the CNAME record

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