Create umd build for react-json-tree (#447)

This commit is contained in:
Mihail Diordiev 2019-01-05 19:38:06 +02:00 committed by GitHub
parent e67bc5a622
commit 7c3b78d312
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 68 additions and 6 deletions

View File

@ -1,11 +1,13 @@
{
"name": "react-json-tree",
"version": "0.11.1",
"version": "0.11.2",
"description": "React JSON Viewer Component, Extracted from redux-devtools",
"main": "lib/index.js",
"scripts": {
"clean": "rimraf lib",
"build": "babel src --out-dir lib",
"build:umd": "rimraf ./umd && webpack --progress --config webpack.config.umd.js",
"build:umd:min": "webpack --env.minimize --progress --config webpack.config.umd.js",
"lint": "eslint --max-warnings=0 src test examples/src",
"test":
"npm run lint && NODE_ENV=test mocha --compilers js:babel-core/register --recursive",
@ -14,13 +16,14 @@
"test:cov":
"babel-node ./node_modules/.bin/isparta cover ./node_modules/.bin/_mocha -- --recursive",
"prepare": "npm run build",
"prepublishOnly": "npm run test && npm run clean && npm run build",
"prepublishOnly": "npm run test && npm run clean && npm run build && npm run build:umd && npm run build:umd:min",
"start": "cd examples && npm start",
"precommit": "lint-staged"
},
"files": [
"lib",
"src"
"src",
"umd"
],
"repository": {
"type": "git",
@ -31,7 +34,8 @@
"contributors": [
"Alexander Kuznetsov <alexkuz@gmail.com> (http://kuzya.org/)",
"Dave Vedder <veddermatic@gmail.com> (http://www.eskimospy.com/)",
"Daniele Zannotti <dzannotti@me.com> (http://www.github.com/dzannotti)"
"Daniele Zannotti <dzannotti@me.com> (http://www.github.com/dzannotti)",
"Mihail Diordiev <zalmoxisus@gmail.com> (https://github.com/zalmoxisus)"
],
"license": "MIT",
"bugs": {
@ -42,6 +46,7 @@
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-eslint": "^8.0.1",
"babel-loader": "^7.1.5",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-es3-member-expression-literals": "^6.22.0",
"babel-plugin-transform-es3-property-literals": "^6.22.0",
@ -68,8 +73,11 @@
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-test-renderer": "^16.0.0",
"rimraf": "^2.5.2"
},
"rimraf": "^2.5.2",
"terser-webpack-plugin": "^1.2.1",
"webpack": "^4.27.1",
"webpack-cli": "^3.2.0"
},
"peerDependencies": {
"react": "^15.0.0 || ^16.0.0",
"react-dom": "^15.0.0 || ^16.0.0"

View File

@ -0,0 +1,54 @@
const path = require('path');
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
module.exports = (env = {}) => (
{
mode: 'production',
entry: {
app: ['./src/index.js']
},
output: {
library: 'ReactJsonTree',
libraryTarget: 'umd',
path: path.resolve(__dirname, 'umd'),
filename: env.minimize ? 'react-json-tree.min.js' : 'react-json-tree.js'
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
}
]
},
externals: {
react: {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react'
},
'react-dom': {
root: 'ReactDOM',
commonjs2: 'react-dom',
commonjs: 'react-dom',
amd: 'react-dom'
}
},
optimization: {
minimize: !!env.minimize,
minimizer: [
new TerserPlugin({
terserOptions: {
safari10: true
}
})
]
},
performance: {
hints: false
}
}
);