Babel v6、react-intl v2、および webpack を使用して、ソース コードから JSON ファイルにメッセージを抽出したいと考えています。すべて正常にコンパイルされていますが、何も抽出されていません。react-intl の v2 を適切にメッセージを抽出するにはどうすればよいですか?
オプションがありますmessagesDir
:
私はもう試した:
- ここからの新しいファイル
.babel.rc
: https://github.com/yahoo/babel-plugin-react-intl/issues/23 – おそらくスペルミスの名前.babelrc
です。 - 新しいファイル
.babelrc
:
{
"extra": {
"react-intl": {
"messagesDir": "./i18n",
"enforceDescriptions": true
}
}
}
webpack構成を使用
{ test: /\.js$/,
loader: 'babel-loader',
query: {
// react needed for JSX syntax
// es2015 needed for modules
// stage0 needed to do splats (...variable)
presets: ['react', 'es2015', 'stage-0'],
// react-intl extracts i18n messages to a shared file
// add-module-exports removes the need to do `require('a').default`
plugins: ['react-intl', 'add-module-exports'],
cacheDirectory: true
},
exclude: /node_modules|bower_components/
},
エラーメッセージとして「index.js: Unknown option: /.babelrc.extra」が表示されます。
extra
上記のプロパティを上記の webpack 構成にも追加しようとしました。非常によく似たエラー メッセージが表示されます。
バージョン:
✗ npm ls | grep "intl"
├─┬ babel-plugin-react-intl@2.0.0
│ └── intl-messageformat-parser@1.2.0
├── intl@1.0.1
├── intl-locales-supported@1.0.0
├── intl-messageformat@1.2.0
├─┬ react-intl@2.0.0-pr-3
│ ├── intl-format-cache@2.0.4