Skip to content

Commit 3acb007

Browse files
committed
Simplify the Rollup build to one command.
1 parent f43a085 commit 3acb007

File tree

3 files changed

+77
-76
lines changed

3 files changed

+77
-76
lines changed

CONTRIBUTING.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -47,30 +47,6 @@ Running the `build` task will create a CommonJS module-per-module build, a ES Mo
4747
npm run build
4848
```
4949

50-
To create just a CommonJS module-per-module build:
51-
52-
```
53-
npm run build:commonjs
54-
```
55-
56-
The result will be in the `lib` folder.
57-
58-
To create just a ES Modules build:
59-
60-
```
61-
npm run build:es
62-
```
63-
64-
The result will be in the `es` folder.
65-
66-
To create just a UMD build:
67-
```
68-
npm run build:umd
69-
npm run build:umd:min
70-
```
71-
72-
The result will be in the `dist` folder.
73-
7450
### Testing and Linting
7551

7652
To only run linting:

package.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,11 @@
3939
"format": "prettier --write \"{src,test}/**/*.{js,ts}\" index.d.ts",
4040
"format:check": "prettier --list-different \"{src,test}/**/*.{js,ts}\" index.d.ts",
4141
"lint": "eslint src test",
42-
"pretest": "npm run build:commonjs",
42+
"pretest": "npm run build",
4343
"test": "cross-env BABEL_ENV=commonjs jest",
4444
"test:watch": "npm test -- --watch",
4545
"test:cov": "npm test -- --coverage",
46-
"build:commonjs": "cross-env NODE_ENV=cjs rollup -c -o lib/redux.js",
47-
"build:es": "cross-env BABEL_ENV=es NODE_ENV=es rollup -c -o es/redux.js",
48-
"build:umd": "cross-env BABEL_ENV=es NODE_ENV=development rollup -c -o dist/redux.js",
49-
"build:umd:min": "cross-env BABEL_ENV=es NODE_ENV=production rollup -c -o dist/redux.min.js",
50-
"build": "npm run build:commonjs && npm run build:es && npm run build:umd && npm run build:umd:min",
46+
"build": "rollup -c",
5147
"prepare": "npm run clean && npm run format:check && npm run lint && npm test && npm run build",
5248
"examples:lint": "eslint examples",
5349
"examples:test": "cross-env CI=true babel-node examples/testAll.js"

rollup.config.js

Lines changed: 75 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,78 @@ import babel from 'rollup-plugin-babel'
33
import replace from 'rollup-plugin-replace'
44
import { terser } from 'rollup-plugin-terser'
55

6-
const env = process.env.NODE_ENV
7-
const config = {
8-
input: 'src/index.js',
9-
plugins: []
10-
}
11-
12-
if (env === 'es' || env === 'cjs') {
13-
config.output = { format: env, indent: false }
14-
config.external = ['symbol-observable']
15-
config.plugins.push(
16-
babel({
17-
plugins: ['external-helpers'],
18-
})
19-
)
20-
}
21-
22-
if (env === 'development' || env === 'production') {
23-
config.output = { format: 'umd', name: 'Redux', indent: false }
24-
config.plugins.push(
25-
nodeResolve({
26-
jsnext: true
27-
}),
28-
babel({
29-
exclude: 'node_modules/**',
30-
plugins: ['external-helpers'],
31-
}),
32-
replace({
33-
'process.env.NODE_ENV': JSON.stringify(env)
34-
})
35-
)
36-
}
37-
38-
if (env === 'production') {
39-
config.plugins.push(
40-
terser({
41-
compress: {
42-
pure_getters: true,
43-
unsafe: true,
44-
unsafe_comps: true,
45-
warnings: false
46-
}
47-
})
48-
)
49-
}
50-
51-
export default config
6+
export default [
7+
{
8+
input: 'src/index.js',
9+
output: { file: 'lib/redux.js', format: 'cjs', indent: false },
10+
external: ['symbol-observable'],
11+
plugins: [
12+
babel({
13+
plugins: ['external-helpers']
14+
})
15+
]
16+
},
17+
{
18+
input: 'src/index.js',
19+
output: { file: 'es/redux.js', format: 'es', indent: false },
20+
external: ['symbol-observable'],
21+
plugins: [
22+
babel({
23+
env: 'es',
24+
plugins: ['external-helpers']
25+
})
26+
]
27+
},
28+
{
29+
input: 'src/index.js',
30+
output: {
31+
file: 'dist/redux.js',
32+
format: 'umd',
33+
name: 'Redux',
34+
indent: false
35+
},
36+
plugins: [
37+
nodeResolve({
38+
jsnext: true
39+
}),
40+
babel({
41+
env: 'es',
42+
exclude: 'node_modules/**',
43+
plugins: ['external-helpers']
44+
}),
45+
replace({
46+
'process.env.NODE_ENV': JSON.stringify('development')
47+
})
48+
]
49+
},
50+
{
51+
input: 'src/index.js',
52+
output: {
53+
file: 'dist/redux.min.js',
54+
format: 'umd',
55+
name: 'Redux',
56+
indent: false
57+
},
58+
plugins: [
59+
nodeResolve({
60+
jsnext: true
61+
}),
62+
babel({
63+
env: 'es',
64+
exclude: 'node_modules/**',
65+
plugins: ['external-helpers']
66+
}),
67+
replace({
68+
'process.env.NODE_ENV': JSON.stringify('production')
69+
}),
70+
terser({
71+
compress: {
72+
pure_getters: true,
73+
unsafe: true,
74+
unsafe_comps: true,
75+
warnings: false
76+
}
77+
})
78+
]
79+
}
80+
]

0 commit comments

Comments
 (0)