Skip to content

Commit

Permalink
bundle js and css of embed
Browse files Browse the repository at this point in the history
  • Loading branch information
skzap committed Mar 7, 2020
1 parent 2607692 commit e569b9c
Show file tree
Hide file tree
Showing 16 changed files with 210 additions and 108 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
2 changes: 2 additions & 0 deletions bin/dtube.css

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions bin/dtube.min.js

Large diffs are not rendered by default.

57 changes: 57 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
var fs = require('fs')
var terser = require("terser")
var ccss = require('clean-css')

var binPath = './bin/'
var css = []
var js = []
css.push("./videojs.css")
css.push("./player.css")
js.push("./lib/lightrpc.min.js")
js.push("./lib/swiftclick.min.js")
js.push("./lib/playerjs.min.js")
js.push("./javascripts/video.js")
js.push("./lib/videojs-contrib-hls.min.js")
js.push("./javascripts/jsoun.js")
js.push("./javascripts/localstorage.js")
js.push("./javascripts/branding.js")
js.push("./javascripts/persistvolume.js")
js.push("./javascripts/resolutionswitcher.js")
js.push("./javascripts/ipfsgatewayswitcher.js")
js.push("./javascripts/settingsmenubuttons.js")
js.push("./javascripts/settingsmenuitem.js")
js.push("./javascripts/hotkeys.js")
js.push("./javascripts/thumbnails.js")
js.push("./javascripts/player.js")
js.push("./javascripts/statistics.js")
js.push("./javascripts/graph.js")
js.push("./javascripts/snap.js")

var cssBundle = ""
for (let i = 0; i < css.length; i++) {
console.log('minifying '+css[i])
var code = fs.readFileSync(css[i],'utf8')
var clean = new ccss({}).minify(code)
for (let y = 0; y < clean.errors.length; y++)
console.log('css error:', css[i], clean.errors[y])
for (let y = 0; y < clean.warnings.length; y++)
console.log('css warn:', css[i], clean.warnings[y])

cssBundle += clean.styles+'\n'
}
fs.writeFileSync(binPath+'dtube.css', cssBundle)
console.log('CSS minified in '+binPath+'dtube.css')

var jsBundle = ""
for (let i = 0; i < js.length; i++) {
console.log('minifying '+js[i])
var code = fs.readFileSync(js[i],'utf8')
var ugly = terser.minify(code)
if (ugly.error)
throw new Error(ugly.error)
jsBundle += ugly.code+'\n'
}
fs.writeFileSync(binPath+'dtube.min.js', jsBundle)
console.log('JS minified in '+binPath+'dtube.min.js')


31 changes: 31 additions & 0 deletions debug.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">

<link href="videojs.css" rel="stylesheet">
<link href="player.css" rel="stylesheet">

<script src="./lib/lightrpc.min.js"></script>
<script src="./lib/swiftclick.min.js"></script>
<script src="./lib/playerjs.min.js"></script>
<script src="./javascripts/video.js"></script>
<script src="./lib/videojs-contrib-hls.min.js"></script>
<script src="./javascripts/jsoun.js"></script>
<script src="./javascripts/localstorage.js"></script>
<script src="./javascripts/branding.js"></script>
<script src="./javascripts/persistvolume.js"></script>
<script src="./javascripts/resolutionswitcher.js"></script>
<script src="./javascripts/ipfsgatewayswitcher.js"></script>
<script src="./javascripts/settingsmenubuttons.js"></script>
<script src="./javascripts/settingsmenuitem.js"></script>
<script src="./javascripts/hotkeys.js"></script>
<script src="./javascripts/thumbnails.js"></script>
<script src="./javascripts/player.js"></script>
<script src="./javascripts/statistics.js"></script>
<script src="./javascripts/graph.js"></script>
<script src="./javascripts/snap.js"></script>
</head>
<body style='margin:0'>
<canvas style="display: none"></canvas>
</body>
</html>
28 changes: 3 additions & 25 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,30 +1,8 @@
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="videojs.css" rel="stylesheet">
<link href="player.css" rel="stylesheet">

<script src="./javascripts/lib/lightrpc.min.js"></script>
<script src="./javascripts/lib/swiftclick.min.js"></script>
<script src="./javascripts/lib/playerjs.min.js"></script>
<script src="./javascripts/jsoun.js"></script>
<script src="./javascripts/localstorage.js"></script>
<script src="./javascripts/video.js"></script>
<script src="./javascripts/videojs-contrib-hls.min.js"></script>
<script src="./javascripts/branding.js"></script>
<script src="./javascripts/persistvolume.js"></script>
<script src="./javascripts/resolutionswitcher.js"></script>
<script src="./javascripts/ipfsgatewayswitcher.js"></script>
<script src="./javascripts/settingsmenubuttons.js"></script>
<script src="./javascripts/settingsmenuitem.js"></script>
<script src="./javascripts/hotkeys.js"></script>
<script src="./javascripts/thumbnails.js"></script>
<script src="./javascripts/player.js"></script>
<script src="./javascripts/statistics.js"></script>
<script src="./javascripts/graph.js"></script>
<script src="./javascripts/snap.js"></script>
<link href="./bin/dtube.css" rel="stylesheet">
<script src="./bin/dtube.min.js"></script>
</head>
<body style='margin:0'>
<canvas style="display: none"></canvas>
</body>
<body style='margin:0'></body>
</html>
31 changes: 0 additions & 31 deletions javascripts/plugin.scss

This file was deleted.

6 changes: 0 additions & 6 deletions javascripts/resolutionswitcher.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/*! videojs-resolution-switcher - 2015-7-26
* Copyright (c) 2016 Kasper Moskwiak
* Modified by Pierre Kraft and Derk-Jan Hartman
* Licensed under the Apache-2.0 license.
* https://github.com/kmoskwiak/videojs-resolution-switcher */

(function() {
'use strict';
var videojs = null;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
56 changes: 56 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "dtube-embed",
"version": "0.9.1",
"description": "embed player for d.tube",
"main": "build.js",
"scripts": {
"build": "node build.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/dtube/embed.git"
},
"keywords": [
"dtube",
"video",
"embed",
"player"
],
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/dtube/embed/issues"
},
"homepage": "https://github.com/dtube/embed#readme",
"devDependencies": {
"clean-css": "^4.2.3",
"terser": "^4.6.6"
}
}
2 changes: 1 addition & 1 deletion player.css
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ li {
font-size: 1em;
}

*/ .vjs-menu-item {
.vjs-menu-item {
text-align: center;
}

Expand Down
45 changes: 0 additions & 45 deletions player.scss

This file was deleted.

0 comments on commit e569b9c

Please sign in to comment.