Skip to content

Commit efac488

Browse files
committed
Added rollup config for babel with react
1 parent 819a6dd commit efac488

8 files changed

+1638
-24
lines changed

Diff for: .babelrc

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"presets": [
3+
[
4+
"@babel/env",
5+
{
6+
"modules": false,
7+
"targets": {
8+
"browsers": "> 0.25%, ie 11, not op_mini all, not dead",
9+
"node": 8
10+
}
11+
}
12+
],
13+
"@babel/react"
14+
]
15+
}

Diff for: .eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist
2+
3+
node_modules

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
dist
2+
13
node_modules

Diff for: .prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist
2+
3+
node_modules

Diff for: package-lock.json

+1,561-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+12-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"description": "React Spinner CSS",
55
"main": "index.js",
66
"scripts": {
7+
"prebuild": "rimraf dist",
8+
"build": "rollup -c",
79
"format": "eslint **/*.js && prettier **/*.js",
810
"format:fix": "eslint **/*.js --fix && prettier **/*.js --write"
911
},
@@ -34,6 +36,10 @@
3436
},
3537
"homepage": "https://github.com/amareshsm/react-spinner-css#readme",
3638
"devDependencies": {
39+
"@babel/core": "^7.10.5",
40+
"@babel/preset-env": "^7.10.4",
41+
"@babel/preset-react": "^7.10.4",
42+
"@rollup/plugin-babel": "^5.1.0",
3743
"eslint": "^7.5.0",
3844
"eslint-config-prettier": "^6.11.0",
3945
"eslint-config-standard": "^14.1.1",
@@ -44,9 +50,13 @@
4450
"eslint-plugin-react": "^7.20.3",
4551
"eslint-plugin-standard": "^4.0.1",
4652
"husky": "^4.2.5",
47-
"lint-staged": "^10.2.11"
53+
"lint-staged": "^10.2.11",
54+
"rimraf": "^3.0.2",
55+
"rollup": "^2.22.2",
56+
"rollup-plugin-node-resolve": "^5.2.0",
57+
"rollup-plugin-terser": "^6.1.0"
4858
},
4959
"dependencies": {
5060
"prettier": "^2.0.5"
5161
}
52-
}
62+
}

Diff for: rollup.config.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import babel from '@rollup/plugin-babel'
2+
import resolve from 'rollup-plugin-node-resolve'
3+
import { terser } from 'rollup-plugin-terser'
4+
5+
const dist = 'dist'
6+
const bundle = 'bundle'
7+
const production = !process.env.ROLLUP_WATCH
8+
9+
export default {
10+
input: 'src/index.js',
11+
external: ['react'],
12+
output: [
13+
{
14+
file: `${dist}/${bundle}.cjs.js`,
15+
format: 'cjs',
16+
},
17+
{
18+
file: `${dist}/${bundle}.esm.js`,
19+
format: 'esm',
20+
},
21+
{
22+
name: 'ReactSpinnerCSS',
23+
file: `${dist}/${bundle}.umd.js`,
24+
globals: {
25+
react: 'React',
26+
},
27+
format: 'umd',
28+
},
29+
],
30+
plugins: [
31+
resolve(),
32+
babel({
33+
exclude: 'node_modules/**',
34+
}),
35+
production && terser(),
36+
],
37+
}

Diff for: src/index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
console.log('hello' + 'world');
1+
import React from 'react'
2+
3+
const Spinner = (props) => <h1>Spinners</h1>
4+
5+
export default Spinner

0 commit comments

Comments
 (0)