React-map-gl: Readme instructions on ejecting create-react-app not clear

Created on 11 Jul 2017  路  3Comments  路  Source: visgl/react-map-gl

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.

docs

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.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.

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

huaying picture huaying  路  5Comments

tbergman picture tbergman  路  3Comments

jenyeeiam picture jenyeeiam  路  4Comments

porteron picture porteron  路  5Comments

Majaspic picture Majaspic  路  4Comments