Skip to content

Commit 4d4ec0e

Browse files
committed
rollup simplified.
1 parent 9cf64cf commit 4d4ec0e

File tree

3 files changed

+30
-16
lines changed

3 files changed

+30
-16
lines changed

assets/user.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66
"browser": "dist/fetch-browser.js",
77
"main": "fetch-node.js",
88
"scripts": {
9-
"prepublish": "RU_ENV=production npm run build && npm test",
9+
"prepublish": "NODE_ENV=production npm run build && npm test",
1010
"prepush": "npm test",
11-
"build": "npm run build:polyfill && npm run build:ponyfill",
12-
"build:polyfill": "RU_TYPE=polyfill rollup -c",
13-
"build:ponyfill": "RU_TYPE=ponyfill rollup -c",
11+
"build": "rollup -c",
1412
"test": "npm run lint && npm run mocha",
1513
"mocha": "mocha",
1614
"lint": "eslint .",

rollup.config.js

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import path from 'path';
21
import resolve from 'rollup-plugin-node-resolve';
32
import commonjs from 'rollup-plugin-commonjs';
43
import uglify from 'rollup-plugin-uglify';
54

6-
const production = process.env.RU_ENV === 'production';
7-
const polyfill = process.env.RU_TYPE === 'polyfill';
5+
const production = process.env.NODE_ENV === 'production';
6+
const config = {};
87

9-
module.exports = {
8+
config.ponyfill = {
109
input: 'fetch-browser-polyfill.js',
1110
output: {
12-
file: path.join('dist', `fetch-browser${polyfill ? '-polyfill' : ''}.js`),
11+
file: 'dist/fetch-browser.js',
1312
format: 'cjs',
1413
strict: false
1514
},
@@ -21,6 +20,28 @@ module.exports = {
2120
production && uglify(),
2221
],
2322
context: 'this',
24-
banner: polyfill? '' : 'var self = {};',
25-
footer: polyfill? '': 'module.exports = self;'
23+
banner: 'var self = {};',
24+
footer: 'module.exports = self;'
2625
};
26+
27+
config.polyfill = {
28+
input: 'fetch-browser-polyfill.js',
29+
output: {
30+
file: 'dist/fetch-browser-polyfill.js',
31+
format: 'cjs',
32+
strict: false
33+
},
34+
plugins: [
35+
resolve({
36+
browser: true
37+
}),
38+
commonjs(),
39+
production && uglify(),
40+
],
41+
context: 'this'
42+
};
43+
44+
module.exports = [
45+
config.ponyfill,
46+
config.polyfill
47+
];

0 commit comments

Comments
 (0)