Skip to content

Commit 73d031a

Browse files
committed
Modify rollup config
1 parent 6e94a55 commit 73d031a

File tree

6 files changed

+101
-63
lines changed

6 files changed

+101
-63
lines changed

example/Layout.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, {PureComponent} from 'react';
22

3-
import SignaturePad from '../src';
3+
import SignaturePad from '../dist/react-signature-pad-wrapper';
44

55
class Layout extends PureComponent {
66

example/package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"dependencies": {
2626
"@babel/runtime": "^7.3.1",
2727
"bulma": "^0.7.2",
28-
"prop-types": "^15.6.2",
2928
"react": "^16.7.0",
3029
"react-dom": "^16.7.0"
3130
},

package-lock.json

Lines changed: 49 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22
"name": "react-signature-pad-wrapper",
33
"version": "1.2.3",
44
"description": "A React component wrapper for signature_pad",
5-
"main": "dist/react-signature-pad-wrapper.min.js",
5+
"main": "dist/react-signature-pad-wrapper.js",
6+
"module": "dist/react-signature-pad-wrapper.es.js",
67
"files": [
78
"dist"
89
],
910
"scripts": {
1011
"test": "jest",
1112
"build": "./node_modules/.bin/rollup --config",
1213
"watch": "./node_modules/.bin/rollup --config --watch",
13-
"lint": "./node_modules/.bin/eslint ./"
14+
"lint": "./node_modules/.bin/eslint ./",
15+
"clean": "rm -rf dist"
1416
},
1517
"keywords": [
1618
"react",
@@ -52,6 +54,8 @@
5254
"rollup-plugin-commonjs": "^9.2.0",
5355
"rollup-plugin-eslint": "^5.0.0",
5456
"rollup-plugin-node-resolve": "^4.0.0",
57+
"rollup-plugin-sourcemaps": "^0.4.2",
58+
"rollup-plugin-terser": "^4.0.3",
5559
"rollup-plugin-uglify": "^6.0.2"
5660
},
5761
"dependencies": {

rollup.config.js

Lines changed: 40 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,52 @@
11
import commonjs from 'rollup-plugin-commonjs';
22
import resolve from 'rollup-plugin-node-resolve';
33
import babel from 'rollup-plugin-babel';
4+
import sourceMaps from 'rollup-plugin-sourcemaps';
45
import {eslint} from 'rollup-plugin-eslint';
56
import {uglify} from 'rollup-plugin-uglify';
7+
import {terser} from 'rollup-plugin-terser';
8+
9+
import pkg from './package.json';
10+
11+
const base = {
12+
input: 'src/index.js',
13+
external: [
14+
...Object.keys(pkg.dependencies || {}),
15+
...Object.keys(pkg.peerDependencies || {}),
16+
],
17+
watch: {
18+
include: 'src/**'
19+
},
20+
plugins: [
21+
eslint(),
22+
babel({
23+
exclude: 'node_modules/**',
24+
plugins: [
25+
'@babel/plugin-external-helpers',
26+
'@babel/plugin-transform-runtime',
27+
'@babel/plugin-proposal-class-properties',
28+
],
29+
runtimeHelpers: true
30+
}),
31+
commonjs(),
32+
resolve(),
33+
sourceMaps()
34+
]
35+
};
636

737
export default [
838
{
9-
input: 'src/index.js',
10-
output: {
11-
file: 'dist/react-signature-pad-wrapper.min.js',
12-
format: 'cjs',
13-
sourcemap: true
14-
},
15-
plugins: [
16-
eslint(),
17-
babel({
18-
exclude: 'node_modules/**',
19-
plugins: [
20-
'@babel/plugin-external-helpers',
21-
'@babel/plugin-transform-runtime',
22-
'@babel/plugin-proposal-class-properties',
23-
],
24-
runtimeHelpers: true
25-
}),
26-
commonjs(),
27-
resolve({
28-
jsnext: true,
29-
customResolveOptions: {
30-
moduleDirectory: 'node_modules'
31-
}
32-
}),
33-
uglify()
34-
],
35-
external: ['react', 'prop-types']
39+
...base,
40+
...{
41+
output: {file: pkg.main, format: 'cjs', sourcemap: true},
42+
plugins: [...base.plugins, uglify()]
43+
}
3644
},
3745
{
38-
input: 'src/index.js',
39-
output: {
40-
file: 'dist/react-signature-pad-wrapper.js',
41-
format: 'cjs'
42-
},
43-
plugins: [
44-
eslint(),
45-
babel({
46-
exclude: 'node_modules/**',
47-
plugins: [
48-
'@babel/plugin-external-helpers',
49-
'@babel/plugin-transform-runtime',
50-
'@babel/plugin-proposal-class-properties',
51-
],
52-
runtimeHelpers: true
53-
}),
54-
commonjs(),
55-
resolve({
56-
jsnext: true,
57-
customResolveOptions: {
58-
moduleDirectory: 'node_modules'
59-
}
60-
}),
61-
],
62-
external: ['react', 'prop-types']
46+
...base,
47+
...{
48+
output: {file: pkg.module, format: 'es', sourcemap: true},
49+
plugins: [...base.plugins, terser()]
50+
}
6351
}
6452
];

0 commit comments

Comments
 (0)