2020-08-22 03:13:24 +03:00
|
|
|
import * as path from 'path';
|
2021-12-05 06:28:45 +03:00
|
|
|
import * as webpack from 'webpack';
|
2019-01-05 20:38:06 +03:00
|
|
|
|
2021-12-05 06:28:45 +03:00
|
|
|
export default (env: { production?: boolean } = {}): webpack.Configuration => ({
|
2020-08-09 04:18:45 +03:00
|
|
|
mode: env.production ? 'production' : 'development',
|
2019-01-10 21:51:14 +03:00
|
|
|
entry: {
|
2020-08-22 03:13:24 +03:00
|
|
|
app: ['./src/index'],
|
2019-01-10 21:51:14 +03:00
|
|
|
},
|
|
|
|
output: {
|
|
|
|
library: 'ReactJsonTree',
|
2020-08-09 04:18:45 +03:00
|
|
|
libraryExport: 'default',
|
2019-01-10 21:51:14 +03:00
|
|
|
libraryTarget: 'umd',
|
|
|
|
path: path.resolve(__dirname, 'umd'),
|
2020-08-09 04:18:45 +03:00
|
|
|
filename: env.production ? 'react-json-tree.min.js' : 'react-json-tree.js',
|
2019-01-10 21:51:14 +03:00
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
2020-08-22 03:13:24 +03:00
|
|
|
test: /\.(js|ts)x?$/,
|
2019-01-10 21:51:14 +03:00
|
|
|
loader: 'babel-loader',
|
2020-08-08 23:26:39 +03:00
|
|
|
exclude: /node_modules/,
|
|
|
|
},
|
|
|
|
],
|
2019-01-10 21:51:14 +03:00
|
|
|
},
|
2020-08-22 03:13:24 +03:00
|
|
|
resolve: {
|
|
|
|
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
|
|
},
|
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
|
|
|
},
|
|
|
|
});
|