Skip to content

Commit c6cbb2b

Browse files
committed
Use rollup to package app into one file
1 parent 6d20a06 commit c6cbb2b

File tree

16 files changed

+253
-26
lines changed

16 files changed

+253
-26
lines changed

.babelrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
["env", {
44
"targets": {
55
"electron": 1.6
6-
}
6+
},
7+
"modules": false
78
}], "react"
89
]
910
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ jspm_packages
3535

3636
# Optional REPL history
3737
.node_repl_history
38+
dist

index.html

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,21 @@
1919
<script src="node_modules/videojs-contrib-hls/dist/videojs-contrib-hls.min.js"></script>
2020
<script src="node_modules/videojs-ass/src/videojs.ass.js"></script>
2121
<script>
22-
require('babel-register');
23-
require('./src/index.js');
22+
console.log(process.env.NODE_ENV);
23+
if (process.env.NODE_ENV === 'test') {
24+
require('babel-register')({
25+
presets: [
26+
['env', {
27+
targets: {
28+
electron: 1.6
29+
},
30+
}],
31+
'react',
32+
],
33+
});
34+
require('./src/index.js');
35+
} else {
36+
require('./dist/app.min.js');
37+
}
2438
</script>
2539
</html>

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
"author": "Tim Ermilov <yamalight@gmail.com>",
88
"license": "MIT",
99
"scripts": {
10-
"start": "electron .",
10+
"start": "NODE_ENV=test electron .",
11+
"production": "electron .",
1112
"lint": "eslint **/*.js",
1213
"inspect-main": "electron-inspector",
13-
"test": "mocha"
14+
"build": "rollup -c",
15+
"test": "NODE_ENV=test mocha"
1416
},
1517
"devDependencies": {
1618
"babel-core": "^6.24.0",
@@ -27,6 +29,8 @@
2729
"eslint-plugin-react": "^6.10.3",
2830
"mocha": "^3.4.2",
2931
"prettier": "^0.22.0",
32+
"rollup": "^0.45.2",
33+
"rollup-plugin-babel": "^2.7.1",
3034
"spectron": "^3.7.2"
3135
},
3236
"dependencies": {

rollup.config.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import babel from 'rollup-plugin-babel';
2+
3+
export default {
4+
entry: 'src/index.js',
5+
format: 'cjs',
6+
dest: 'dist/app.min.js',
7+
plugins: [babel({exclude: 'node_modules/**'})],
8+
external: [
9+
'big-integer',
10+
'cheerio',
11+
'crypto',
12+
'electron',
13+
'lodash',
14+
'playlist-parser',
15+
'pouchdb-browser',
16+
'react-dom',
17+
'react-router-dom',
18+
'react',
19+
'request-promise-native',
20+
'rxjs',
21+
'xml2js',
22+
'zlib',
23+
],
24+
};

src/api/crunchyroll/getSeries.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import cheerio from 'cheerio';
55
// base url
66
const baseURL = 'http://www.crunchyroll.com';
77

8-
module.exports = async _id => {
8+
export default async _id => {
99
// load catalogue
1010
const url = `${baseURL}${_id}`;
1111
const data = await request(url);

src/api/crunchyroll/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import {M3U} from 'playlist-parser';
66
import electron from 'electron';
77

88
// our packages
9-
import db from '../../db';
9+
import db from '../../db/index';
1010
import parseXml from './parseXml';
11-
import decode from './subtitles';
11+
import decode from './subtitles/index';
1212
import bytesToAss from './subtitles/ass';
1313
import getSeries from './getSeries';
1414

src/api/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// plugins
2-
import Crunchyroll from './crunchyroll';
3-
import Youtube from './youtube';
2+
import Crunchyroll from './crunchyroll/index';
3+
import Youtube from './youtube/index';
44

55
// manager
66
import PluginManager from './manager';

src/api/youtube/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import cheerio from 'cheerio';
55
import electron from 'electron';
66

77
// our packages
8-
import db from '../../db';
8+
import db from '../../db/index';
99

1010
// base URL used for most requests
1111
const baseURL = 'http://youtube.com';

src/components/series/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react';
33
import {withRouter} from 'react-router-dom';
44

55
// our packages
6-
import db from '../../db';
6+
import db from '../../db/index';
77

88
export default withRouter(({series, history}) => {
99
const openSeriesPage = async () => {

0 commit comments

Comments
 (0)