mirror of
https://github.com/visgl/react-map-gl.git
synced 2025-12-08 20:16:02 +00:00
36 lines
987 B
JavaScript
36 lines
987 B
JavaScript
const webpack = require('webpack');
|
|
const {getWebpackConfig} = require('ocular-dev-tools');
|
|
|
|
module.exports = env => {
|
|
const config = getWebpackConfig(env);
|
|
|
|
config.resolve = {...config.resolve, extensions: ['.ts', '.tsx', '.js', '.json']};
|
|
|
|
config.module.rules = [
|
|
...config.module.rules.filter(r => r.loader !== 'babel-loader'),
|
|
{
|
|
// Compile source using babel
|
|
test: /(\.js|\.ts|\.tsx)$/,
|
|
loader: 'babel-loader',
|
|
exclude: [/node_modules/],
|
|
options: {
|
|
presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript'],
|
|
plugins: ['@babel/plugin-proposal-class-properties']
|
|
}
|
|
}
|
|
];
|
|
|
|
config.plugins = (config.plugins || []).concat([
|
|
new webpack.DefinePlugin({
|
|
__MAPBOX_TOKEN__: JSON.stringify(process.env.MapboxAccessToken) // eslint-disable-line
|
|
})
|
|
]);
|
|
|
|
if (env.mode === 'size') {
|
|
// Only measure self bundle size
|
|
config.externals = ['mapbox-gl'];
|
|
}
|
|
|
|
return config;
|
|
};
|