diff --git a/config/jest/client.config.js b/config/jest/client.config.js index 421848cc5..816d58b7b 100644 --- a/config/jest/client.config.js +++ b/config/jest/client.config.js @@ -29,6 +29,7 @@ module.exports = { "^coral-account/(.*)$": "/src/core/client/account/$1", "^coral-admin/(.*)$": "/src/core/client/admin/$1", "^coral-auth/(.*)$": "/src/core/client/auth/$1", + "^coral-count/(.*)$": "/src/core/client/count/$1", "^coral-ui/(.*)$": "/src/core/client/ui/$1", "^coral-stream/(.*)$": "/src/core/client/stream/$1", "^coral-framework/(.*)$": "/src/core/client/framework/$1", diff --git a/src/core/build/createWebpackConfig.ts b/src/core/build/createWebpackConfig.ts index 4a2452400..22fbb8daa 100644 --- a/src/core/build/createWebpackConfig.ts +++ b/src/core/build/createWebpackConfig.ts @@ -752,5 +752,44 @@ export default function createWebpackConfig( ), ]), }, + /* Webpack config for count */ + { + ...baseConfig, + optimization: { + ...baseConfig.optimization, + // Ensure that we never split the count into chunks. + splitChunks: { + chunks: "async", + }, + // We can turn on sideEffects here as we don't use + // css here and don't run into: https://github.com/webpack/webpack/issues/7094 + sideEffects: true, + }, + entry: [paths.appCountIndex], + output: { + ...baseConfig.output, + // don't hash the count, cache-busting must be completed by the requester + // as this lives in a static template on the embed site. + filename: "assets/js/count.js", + }, + plugins: filterPlugins([ + ...baseConfig.plugins!, + ...ifWatch( + // Generates an `embed.html` file with the