-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
All locale data included in bundle #232
Comments
I was inspecting my bundle size and noticed the same thing. @wiziple any update here why the PR could not be merged? |
Quickfix for existing sites: exports.onCreateWebpackConfig = ({ stage, actions, getConfig }) => {
…
// Get languages from gatsby-plugin-intl plugin options
// Access the plugin options directly from the Gatsby config
const gatsbyConfig = require('./gatsby-config');
const intlPlugin = gatsbyConfig.plugins.find(plugin =>
typeof plugin === 'object' && plugin.resolve === 'gatsby-plugin-intl'
);
const languages = intlPlugin?.options?.languages;
const regex = new RegExp(languages.map((l) => l.split("-")[0]).join("|"));
actions.setWebpackConfig({
plugins: [
new webpack.ContextReplacementPlugin(
/@formatjs[/\\]intl-relativetimeformat[/\\]locale-data$/,
regex
),
new webpack.ContextReplacementPlugin(
/@formatjs[/\\]intl-pluralrules[/\\]locale-data$/,
regex
),
],
});
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Since intl-relativetimeformat 6.0, the locales are no longer located in the dist subfolder (https://github.com/formatjs/formatjs/blob/main/packages/intl-relativetimeformat/CHANGELOG.md#600-2020-07-03). As a consequence, this line has no effect:
https://github.com/wiziple/gatsby-plugin-intl/blob/master/src/gatsby-node.js#L29
The fix is probably to just remove the
dist[/\\]
part but I haven't tried.The text was updated successfully, but these errors were encountered: