The readme states the following:
create-react-app- At this point configuration-free builds are not possible with webpack. You will need to eject your app (sorry) and add one line alias to your webpack config.For more information, please refer to the docs docs.
However, I can't find the one line alias that I have to add. Following the link to the docs takes me to a page with no alias instructions.
P.S On a minor point, there's also a duplication of the word "docs" in that last sentence - the non-hyperlink version is not needed.
To answer my own question, it looks like the following code needs to be merged into my create-react-app/config/webpack.config.dev.js file (which can be found in your webpack example):
resolve: {
alias: {
// From mapbox-gl-js README. Required for non-browserify bundlers (e.g. webpack):
'mapbox-gl$': path.resolve('./node_modules/mapbox-gl/dist/mapbox-gl.js')
}
}
Note: In this example, path should already be defined. If not, add const path = require('path'); to the top of the file.
The readme should still be updated to make this solution clearer.
In my app, the webpack.config.dev.js already has the resolve element, then i add alias to the resolve alias element:
resolve: {
...something
alias: {
'react-native': 'react-native-web',
'mapbox-gl$': path.join(paths.appNodeModules, '/mapbox-gl/dist/mapbox-gl.js')
},
...something
},
NOTE: the paths should be defined like const paths = require('./paths'); if the app is not define it.
Hope i can help others.
create-react-app is working on the latest release.
Most helpful comment
To answer my own question, it looks like the following code needs to be merged into my
create-react-app/config/webpack.config.dev.jsfile (which can be found in your webpack example):Note: In this example,
pathshould already be defined. If not, addconst path = require('path');to the top of the file.The readme should still be updated to make this solution clearer.