我想使用react-intl-webpack-plugin将来自babel-plugin-react-intl的消息合并到一个消息文件中。我已经配置了webpack.config.dev.js,但是,当我运行“ yarn start”时,出现以下错误:
Cannot read property 'compilation' of undefined
我按照说明设置了react-intl-webpack-plugin。 webpack.config.dev.js中的相关配置如下所示:
const ReactIntlPlugin = require('react-intl-webpack-plugin');
...
module.exports = {
...
resolve: {
...
plugins: [
new ReactIntlPlugin()
],
},
module: {
...
// Process JS with Babel.
{
test: /\.(js|jsx|mjs)$/,
include: paths.appSrc,
loader: require.resolve('babel-loader'),
options: {
cacheDirectory: true,
metadataSubscribers: [ReactIntlPlugin.metadataContextFunctionName],
presets: ['env', 'react-app'],
plugins: [
'transform-runtime',
['react-intl', {
'messagesDir': './public/messages/',
'enforceDescriptions': false
}]
]
},
...
我的项目由create-react-app创建,然后弹出。 webpack和react-intl-webpack-plugin的版本分别为3.8.1和0.3.0。
谢谢。