ognian / react-intl-webpack-plugin Goto Github PK
View Code? Open in Web Editor NEWa webpack plugin to collect messages from the react-intl babel plugin
License: Other
a webpack plugin to collect messages from the react-intl babel plugin
License: Other
As described in your docs, I added the metadataSubscribers option to my Babel config but it seems that this option is (not more) supported by Babel:
module: {
rules: [
{
test: /\.jsx?$/, // A regexp to test the require path. accepts either js or jsx
loader: 'babel-loader',
query: {
"metadataSubscribers": [ReactIntlPlugin.metadataContextFunctionName],
Webpack returns the following error:
ERROR in ./src/app/main.js
Module build failed: ReferenceError: [BABEL] ~/client/src/app/main.js: Unknown option: base.metadataSubscribers. Check out http://babeljs.io/docs/usage/options/ for more information about options.
Is it possible to change the output file name? Can that be set via an option perhaps?
using .babelrc file like this:
{
"presets": ["es2015", "react", "stage-2"],
"metadataSubscribers": "metadataReactIntlPlugin",
"plugins" : [
[
"react-intl", {
"messagesDir": "./public/build/messages",
"enforceDescriptions": false
}
]
]
}
gives this error:
Unknown option: /.babelrc.metadataSubscribers.
I'm using:
"babel-core": "^6.24.0",
"babel-loader": "^6.4.1",
"babel-plugin-react-intl": "^2.3.1",
"babel-preset-env": "^1.1.4",
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-2": "^6.22.0",
I also added:
new ReactIntlPlugin() to the plugins array on the webpack.config.js any ideas?
@Ognian - thank you for writing this plugin. I think it's exactly what I was hoping for. That said, I tried to follow your workflow, but my reactIntlMessages.json file contents are []
, indicating an empty array.
Here's what I've done so far:
"babel-loader": "git://github.com/Ognian/babel-loader.git#passthru_metadata",
<IntlProvider>
, imported from react-intl.import FormattedMessage from 'react-intl';
<FormattedMessage id="sample_message_id" defaultMessage="Sample Message" />
const ReactIntlPlugin=require('react-intl-webpack-plugin');
...
plugins: [
...
new ReactIntlPlugin(),
],
module: {
loaders: [
...
{
test: /\.jsx?$/, loader: 'babel-loader', exclude: /node_modules/,
query: {
"cacheDirectory": true,
"metadataSubscribers":[ReactIntlPlugin.metadataContextFunctionName],
"plugins": ["transform-runtime",
["react-intl", {
"enforceDescriptions": false
}]],
"presets": ['react', "es2015", "stage-1"]
}
},
],
},
When I build, the reactIntlMessages.json file is created, but there aren't any strings in it--just []
.
Any hints on what I might be doing wrong or missing? Thanks in advance!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.