2019-01-05 20:38:06 +03:00
|
|
|
const path = require('path');
|
|
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
|
|
|
2019-01-10 21:51:14 +03:00
|
|
|
module.exports = (env = {}) => ({
|
|
|
|
mode: 'production',
|
|
|
|
entry: {
|
2020-08-08 23:26:39 +03:00
|
|
|
app: ['./src/index.js'],
|
2019-01-10 21:51:14 +03:00
|
|
|
},
|
|
|
|
output: {
|
|
|
|
library: 'ReactJsonTree',
|
|
|
|
libraryTarget: 'umd',
|
|
|
|
path: path.resolve(__dirname, 'umd'),
|
2020-08-08 23:26:39 +03:00
|
|
|
filename: env.minimize ? 'react-json-tree.min.js' : 'react-json-tree.js',
|
2019-01-10 21:51:14 +03:00
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
loader: 'babel-loader',
|
2020-08-08 23:26:39 +03:00
|
|
|
exclude: /node_modules/,
|
|
|
|
},
|
|
|
|
],
|
2019-01-10 21:51:14 +03:00
|
|
|
},
|
|
|
|
externals: {
|
|
|
|
react: {
|
|
|
|
root: 'React',
|
|
|
|
commonjs2: 'react',
|
|
|
|
commonjs: 'react',
|
2020-08-08 23:26:39 +03:00
|
|
|
amd: 'react',
|
2019-01-05 20:38:06 +03:00
|
|
|
},
|
2019-01-10 21:51:14 +03:00
|
|
|
'react-dom': {
|
|
|
|
root: 'ReactDOM',
|
|
|
|
commonjs2: 'react-dom',
|
|
|
|
commonjs: 'react-dom',
|
2020-08-08 23:26:39 +03:00
|
|
|
amd: 'react-dom',
|
|
|
|
},
|
2019-01-10 21:51:14 +03:00
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
minimize: !!env.minimize,
|
|
|
|
minimizer: [
|
|
|
|
new TerserPlugin({
|
|
|
|
terserOptions: {
|
2020-08-08 23:26:39 +03:00
|
|
|
safari10: true,
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
],
|
2019-01-10 21:51:14 +03:00
|
|
|
},
|
|
|
|
performance: {
|
2020-08-08 23:26:39 +03:00
|
|
|
hints: false,
|
|
|
|
},
|
2019-01-10 21:51:14 +03:00
|
|
|
});
|