Skip to content
This repository was archived by the owner on Nov 6, 2019. It is now read-only.
This repository was archived by the owner on Nov 6, 2019. It is now read-only.

Really want to use this but can't figure out how #29

@martinmckenna

Description

@martinmckenna

I'm using webpack with ts-loader and I'd like to extract my react-intl strings to JSON files.

But I can't figure out how to get this plugin working correctly. I've tried looking at other issues and still can't find any help.

For starters, how do I tell this plugin where to create the JSON file? Also, how am I supposed to be using the onMsgExtracted property

This is what I've tried so far:

webpack.config

          {
            test: /\.(ts|tsx)$/,
            include: paths.appSrc,
            use: [
              {
                loader: require.resolve('ts-loader'),
                options: {
                  // disable type checker - we will use it in fork plugin
                  transpileOnly: true,
                  getCustomTransformers: () => ({
                    before: [
                      intl.transform({
                        idPrefix: "prefix",
                        onMsgExtracted: intl.aggregate({}),
                      }),
                    ]
                  })
                },
              },
            ],
          },

MyComponent.tsx

import { FormattedMessage } from 'react-intl';

export class SummaryPanel extends React.Component<Props, {}> {
  render() {
    return (
      <React.Fragment>
        <FormattedMessage
          defaultMessage="Contact Information"
          id="ContactInfo.heading"
        />
      </React.Fragment>
    );
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions