Skip to content

Commit 9c94729

Browse files
author
Peng Jie
authored
Merge pull request #276 from neighborhood999/chore/build
2 parents 45e06c2 + d6f41fa commit 9c94729

File tree

5 files changed

+107
-20
lines changed

5 files changed

+107
-20
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/example
2+
dist/

.size-snapshot.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
{
22
"dist/js/react-gh-like-diff.cjs.js": {
3-
"bundled": 13571,
4-
"minified": 7301,
5-
"gzipped": 2741
3+
"bundled": 6083,
4+
"minified": 6044,
5+
"gzipped": 2517
66
},
77
"dist/js/react-gh-like-diff.esm.js": {
8-
"bundled": 13290,
9-
"minified": 7071,
10-
"gzipped": 2673,
8+
"bundled": 5968,
9+
"minified": 5929,
10+
"gzipped": 2487,
1111
"treeshaked": {
1212
"rollup": {
13-
"code": 5915,
13+
"code": 5876,
1414
"import_statements": 211
1515
},
1616
"webpack": {
17-
"code": 7073
17+
"code": 7034
1818
}
1919
}
2020
},
2121
"dist/js/react-gh-like-diff.umd.js": {
22-
"bundled": 14934,
23-
"minified": 6403,
24-
"gzipped": 2614
22+
"bundled": 6403,
23+
"minified": 6364,
24+
"gzipped": 2609
2525
}
2626
}

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"test:watch": "npm test -- --watch",
1212
"test:cov": "npm run lint && jest --coverage",
1313
"clean": "rimraf lib es dist",
14-
"build": "npm run clean && rollup -c",
14+
"build:dev": "npm run clean && cross-env NODE_ENV=development rollup -c",
15+
"build": "npm run clean && cross-env NODE_ENV=production rollup -c",
1516
"size": "bundlesize",
1617
"lint": "eslint src"
1718
},
@@ -76,11 +77,13 @@
7677
"@rollup/plugin-buble": "0.21.1",
7778
"@rollup/plugin-commonjs": "11.0.2",
7879
"@rollup/plugin-node-resolve": "7.1.1",
80+
"@rollup/plugin-replace": "^2.3.2",
7981
"@testing-library/jest-dom": "5.3.0",
8082
"@testing-library/react": "10.0.2",
8183
"babel-eslint": "10.1.0",
8284
"bundlesize": "0.18.0",
8385
"codecov": "3.6.5",
86+
"cross-env": "^7.0.2",
8487
"eslint": "6.8.0",
8588
"eslint-config-prettier": "6.10.1",
8689
"eslint-plugin-jest": "23.8.2",
@@ -96,7 +99,8 @@
9699
"rollup": "2.3.3",
97100
"rollup-plugin-css-only": "2.0.0",
98101
"rollup-plugin-node-builtins": "2.1.2",
99-
"rollup-plugin-size-snapshot": "0.11.0"
102+
"rollup-plugin-size-snapshot": "0.11.0",
103+
"rollup-plugin-terser": "^5.3.0"
100104
},
101105
"peerDependencies": {
102106
"react": "^16.0.0"

rollup.config.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import builtins from 'rollup-plugin-node-builtins';
44
import commonjs from '@rollup/plugin-commonjs';
55
import nodeResolve from '@rollup/plugin-node-resolve';
66
import css from 'rollup-plugin-css-only';
7+
import replace from '@rollup/plugin-replace';
8+
import { terser } from 'rollup-plugin-terser';
79
import { sizeSnapshot } from 'rollup-plugin-size-snapshot';
810

911
const globals = {
@@ -14,22 +16,29 @@ const globals = {
1416
util: 'util'
1517
};
1618

19+
const env = process.env.NODE_ENV;
20+
1721
const baseConfig = {
1822
input: 'src/index.js',
1923
external: ['react', 'prop-types', 'recompose', 'difflib'],
2024
plugins: [
25+
replace({ 'process.env.NODE_ENV': JSON.stringify(env) }),
26+
builtins(),
27+
nodeResolve({ jsnext: true }),
28+
commonjs({ include: 'node_modules/**' }),
2129
buble({
2230
exclude: 'node_modules/**',
2331
objectAssign: true
2432
}),
25-
builtins(),
26-
nodeResolve({ jsnext: true }),
27-
commonjs({ include: 'node_modules/**' }),
28-
css({ output: 'dist/css/diff2html.min.css' }),
29-
sizeSnapshot()
33+
css({ output: 'dist/css/diff2html.min.css' })
3034
]
3135
};
3236

37+
if (env === 'production') {
38+
baseConfig.plugins.push(terser());
39+
baseConfig.plugins.push(sizeSnapshot());
40+
}
41+
3342
export default [
3443
{
3544
...baseConfig,

yarn.lock

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# yarn lockfile v1
33

44

5-
"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.8.3":
5+
"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.5.5", "@babel/code-frame@^7.8.3":
66
version "7.8.3"
77
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.8.3.tgz#33e25903d7481181534e12ec0a25f16b6fcf419e"
88
integrity sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==
@@ -1171,13 +1171,30 @@
11711171
"@rollup/pluginutils" "^3.0.4"
11721172
magic-string "^0.25.5"
11731173

1174+
"@rollup/plugin-replace@^2.3.2":
1175+
version "2.3.2"
1176+
resolved "https://registry.yarnpkg.com/@rollup/plugin-replace/-/plugin-replace-2.3.2.tgz#da4e0939047f793c2eb5eedfd6c271232d0a033f"
1177+
integrity sha512-KEEL7V2tMNOsbAoNMKg91l1sNXBDoiP31GFlqXVOuV5691VQKzKBh91+OKKOG4uQWYqcFskcjFyh1d5YnZd0Zw==
1178+
dependencies:
1179+
"@rollup/pluginutils" "^3.0.8"
1180+
magic-string "^0.25.5"
1181+
11741182
"@rollup/pluginutils@^3.0.0", "@rollup/pluginutils@^3.0.4", "@rollup/pluginutils@^3.0.6":
11751183
version "3.0.8"
11761184
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.0.8.tgz#4e94d128d94b90699e517ef045422960d18c8fde"
11771185
integrity sha512-rYGeAc4sxcZ+kPG/Tw4/fwJODC3IXHYDH4qusdN/b6aLw5LPUbzpecYbEJh4sVQGPFJxd2dBU4kc1H3oy9/bnw==
11781186
dependencies:
11791187
estree-walker "^1.0.1"
11801188

1189+
"@rollup/pluginutils@^3.0.8":
1190+
version "3.0.10"
1191+
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.0.10.tgz#a659b9025920378494cd8f8c59fbf9b3a50d5f12"
1192+
integrity sha512-d44M7t+PjmMrASHbhgpSbVgtL6EFyX7J4mYxwQ/c5eoaE6N2VgCgEcWVzNnwycIloti+/MpwFr8qfw+nRw00sw==
1193+
dependencies:
1194+
"@types/estree" "0.0.39"
1195+
estree-walker "^1.0.1"
1196+
picomatch "^2.2.2"
1197+
11811198
"@samverschueren/stream-to-observable@^0.3.0":
11821199
version "0.3.0"
11831200
resolved "https://registry.yarnpkg.com/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.0.tgz#ecdf48d532c58ea477acfcab80348424f8d0662f"
@@ -2669,6 +2686,13 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4:
26692686
safe-buffer "^5.0.1"
26702687
sha.js "^2.4.8"
26712688

2689+
cross-env@^7.0.2:
2690+
version "7.0.2"
2691+
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.2.tgz#bd5ed31339a93a3418ac4f3ca9ca3403082ae5f9"
2692+
integrity sha512-KZP/bMEOJEDCkDQAyRhu3RL2ZO/SUVrxQVI0G3YEQ+OLbRA3c6zgixe8Mq8a/z7+HKlNEjo8oiLUs8iRijY2Rw==
2693+
dependencies:
2694+
cross-spawn "^7.0.1"
2695+
26722696
cross-spawn@^6.0.0, cross-spawn@^6.0.5:
26732697
version "6.0.5"
26742698
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
@@ -2689,6 +2713,15 @@ cross-spawn@^7.0.0:
26892713
shebang-command "^2.0.0"
26902714
which "^2.0.1"
26912715

2716+
cross-spawn@^7.0.1:
2717+
version "7.0.2"
2718+
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.2.tgz#d0d7dcfa74e89115c7619f4f721a94e1fdb716d6"
2719+
integrity sha512-PD6G8QG3S4FK/XCGFbEQrDqO2AnMMsy0meR7lerlIOHAAbkuavGU/pOqprrlvfTNjvowivTeBsjebAL0NSoMxw==
2720+
dependencies:
2721+
path-key "^3.1.0"
2722+
shebang-command "^2.0.0"
2723+
which "^2.0.1"
2724+
26922725
crypto-browserify@^3.11.0:
26932726
version "3.12.0"
26942727
resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec"
@@ -4847,6 +4880,14 @@ jest-watcher@^25.2.7:
48474880
jest-util "^25.2.6"
48484881
string-length "^3.1.0"
48494882

4883+
jest-worker@^24.9.0:
4884+
version "24.9.0"
4885+
resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-24.9.0.tgz#5dbfdb5b2d322e98567898238a9697bcce67b3e5"
4886+
integrity sha512-51PE4haMSXcHohnSMdM42anbvZANYTqMrr52tVKPqqsPJMzoP6FYYDVqahX/HrAoKEKz3uUPzSvKs9A3qR4iVw==
4887+
dependencies:
4888+
merge-stream "^2.0.0"
4889+
supports-color "^6.1.0"
4890+
48504891
jest-worker@^25.2.6:
48514892
version "25.2.6"
48524893
resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-25.2.6.tgz#d1292625326794ce187c38f51109faced3846c58"
@@ -6016,6 +6057,11 @@ picomatch@^2.0.4, picomatch@^2.0.5:
60166057
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.1.tgz#21bac888b6ed8601f831ce7816e335bc779f0a4a"
60176058
integrity sha512-ISBaA8xQNmwELC7eOjqFKMESB2VIqt4PPDD0nsS95b/9dZXvVKOlz9keMSnoGGKcOHXfTvDD6WMaRoSc9UuhRA==
60186059

6060+
picomatch@^2.2.2:
6061+
version "2.2.2"
6062+
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad"
6063+
integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==
6064+
60196065
pify@^3.0.0:
60206066
version "3.0.0"
60216067
resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176"
@@ -6653,7 +6699,18 @@ [email protected]:
66536699
terser "^4.6.3"
66546700
webpack "^4.41.5"
66556701

6656-
rollup-pluginutils@^2.3.3:
6702+
rollup-plugin-terser@^5.3.0:
6703+
version "5.3.0"
6704+
resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-5.3.0.tgz#9c0dd33d5771df9630cd027d6a2559187f65885e"
6705+
integrity sha512-XGMJihTIO3eIBsVGq7jiNYOdDMb3pVxuzY0uhOE/FM4x/u9nQgr3+McsjzqBn3QfHIpNSZmFnpoKAwHBEcsT7g==
6706+
dependencies:
6707+
"@babel/code-frame" "^7.5.5"
6708+
jest-worker "^24.9.0"
6709+
rollup-pluginutils "^2.8.2"
6710+
serialize-javascript "^2.1.2"
6711+
terser "^4.6.2"
6712+
6713+
rollup-pluginutils@^2.3.3, rollup-pluginutils@^2.8.2:
66576714
version "2.8.2"
66586715
resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e"
66596716
integrity sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==
@@ -7260,6 +7317,13 @@ supports-color@^5.3.0:
72607317
dependencies:
72617318
has-flag "^3.0.0"
72627319

7320+
supports-color@^6.1.0:
7321+
version "6.1.0"
7322+
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.1.0.tgz#0764abc69c63d5ac842dd4867e8d025e880df8f3"
7323+
integrity sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==
7324+
dependencies:
7325+
has-flag "^3.0.0"
7326+
72637327
supports-color@^7.0.0, supports-color@^7.1.0:
72647328
version "7.1.0"
72657329
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.1.0.tgz#68e32591df73e25ad1c4b49108a2ec507962bfd1"
@@ -7364,6 +7428,15 @@ terser@^4.1.2, terser@^4.6.3:
73647428
source-map "~0.6.1"
73657429
source-map-support "~0.5.12"
73667430

7431+
terser@^4.6.2:
7432+
version "4.6.13"
7433+
resolved "https://registry.yarnpkg.com/terser/-/terser-4.6.13.tgz#e879a7364a5e0db52ba4891ecde007422c56a916"
7434+
integrity sha512-wMvqukYgVpQlymbnNbabVZbtM6PN63AzqexpwJL8tbh/mRT9LE5o+ruVduAGL7D6Fpjl+Q+06U5I9Ul82odAhw==
7435+
dependencies:
7436+
commander "^2.20.0"
7437+
source-map "~0.6.1"
7438+
source-map-support "~0.5.12"
7439+
73677440
test-exclude@^6.0.0:
73687441
version "6.0.0"
73697442
resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-6.0.0.tgz#04a8698661d805ea6fa293b6cb9e63ac044ef15e"

0 commit comments

Comments
 (0)