mirror of
https://github.com/visgl/react-map-gl.git
synced 2026-01-18 15:54:22 +00:00
52 lines
1.4 KiB
JavaScript
52 lines
1.4 KiB
JavaScript
// This file contains webpack configuration settings that allow
|
|
// examples to be built against the deck.gl source code in this repo instead
|
|
// of building against their installed version of deck.gl.
|
|
//
|
|
// This enables using the examples to debug the main deck.gl library source
|
|
// without publishing or npm linking, with conveniences such hot reloading etc.
|
|
|
|
const {resolve} = require('path');
|
|
const webpack = require('webpack');
|
|
|
|
const LIB_DIR = resolve(__dirname, '..');
|
|
const SRC_DIR = resolve(LIB_DIR, './src');
|
|
|
|
// Support for hot reloading changes
|
|
const LOCAL_DEVELOPMENT_CONFIG = {
|
|
// suppress warnings about bundle size
|
|
devServer: {
|
|
stats: {
|
|
warnings: false
|
|
}
|
|
},
|
|
|
|
resolve: {
|
|
alias: {
|
|
// Imports the deck.gl library from the src directory in this repo
|
|
'react-map-gl': SRC_DIR,
|
|
react: resolve(LIB_DIR, './node_modules/react')
|
|
}
|
|
},
|
|
module: {
|
|
rules: []
|
|
},
|
|
// Optional: Enables reading mapbox token from environment variable
|
|
plugins: [
|
|
new webpack.EnvironmentPlugin(['MapboxAccessToken'])
|
|
]
|
|
};
|
|
|
|
function addLocalDevSettings(config) {
|
|
Object.assign(config.resolve.alias, LOCAL_DEVELOPMENT_CONFIG.resolve.alias);
|
|
config.module.rules = config.module.rules.concat(LOCAL_DEVELOPMENT_CONFIG.module.rules);
|
|
return config;
|
|
}
|
|
|
|
module.exports = baseConfig => env => {
|
|
const config = baseConfig;
|
|
if (env && env.local) {
|
|
addLocalDevSettings(config);
|
|
}
|
|
return config;
|
|
};
|