replace `module.exports` with `export default`; separate js and css files into different folder

This commit is contained in:
DIYgod 2018-01-10 18:03:58 +08:00
parent 407a5ba951
commit 100234774d
No known key found for this signature in database
GPG Key ID: EC0B76A252D3EF67
26 changed files with 38 additions and 33 deletions

View File

@ -1,6 +1,6 @@
{
"name": "dplayer",
"version": "1.17.4",
"version": "1.17.5",
"description": "Wow, such a lovely HTML5 danmaku video player",
"main": "dist/DPlayer.min.js",
"style": "dist/DPlayer.min.css",

View File

@ -1,4 +1,4 @@
@import '../node_modules/balloon-css/balloon.css';
@import '../../node_modules/balloon-css/balloon.css';
.dplayer {
position: relative;

View File

@ -1,5 +1,3 @@
import './DPlayer.scss';
import utils, { isMobile } from './utils';
import handleOption from './options';
import i18n from './i18n';
@ -497,4 +495,4 @@ class DPlayer {
}
}
module.exports = DPlayer;
export default DPlayer;

View File

@ -27,7 +27,7 @@ const SendXMLHttpRequest = (url, data, success, error, fail) => {
xhr.send(data !== null ? JSON.stringify(data) : null);
};
module.exports = {
export default {
send: (endpoint, danmakuData, callback) => {
SendXMLHttpRequest(endpoint, danmakuData, (xhr, response) => {
console.log('Post danmaku: ', response);

View File

@ -25,4 +25,4 @@ class Bar {
}
}
module.exports = Bar;
export default Bar;

View File

@ -13,4 +13,4 @@ class Bezel {
}
}
module.exports = Bezel;
export default Bezel;

View File

@ -90,4 +90,4 @@ class Comment {
}
}
module.exports = Comment;
export default Comment;

View File

@ -49,4 +49,4 @@ class ContextMenu {
}
}
module.exports = ContextMenu;
export default ContextMenu;

View File

@ -251,4 +251,4 @@ class Controller {
}
}
module.exports = Controller;
export default Controller;

View File

@ -340,4 +340,4 @@ class Danmaku {
}
}
module.exports = Danmaku;
export default Danmaku;

View File

@ -53,4 +53,4 @@ class Events {
}
}
module.exports = Events;
export default Events;

View File

@ -101,4 +101,4 @@ class FullScreen {
}
}
module.exports = FullScreen;
export default FullScreen;

View File

@ -52,4 +52,4 @@ class HotKey {
}
}
module.exports = HotKey;
export default HotKey;

View File

@ -7,7 +7,7 @@ W3C def language codes is :
NOTE: use lowercase to prevent case typo from user!
Use this as shown below..... */
module.exports = function (lang) {
function i18n (lang) {
this.lang = lang;
this.tran = (text) => {
if (tranTxt[this.lang] && tranTxt[this.lang][text]) {
@ -17,7 +17,7 @@ module.exports = function (lang) {
return text;
}
};
};
}
// add translation text here
const tranTxt = {
@ -93,4 +93,6 @@ const tranTxt = {
'Volume': '音量',
'Live': '直播',
}
};
};
export default i18n;

View File

@ -1,4 +1,7 @@
import '../css/index.scss';
import DPlayer from './DPlayer';
/* global DPLAYER_VERSION GIT_HASH */
console.log(`${'\n'} %c DPlayer ${DPLAYER_VERSION} ${GIT_HASH} %c http://dplayer.js.org ${'\n'}${'\n'}`, 'color: #fadfa3; background: #030307; padding:5px 0;', 'background: #fadfa3; padding:5px 0;');
module.exports = require('./DPlayer');
export default DPlayer;

View File

@ -1,7 +1,7 @@
/* global DPLAYER_VERSION GIT_HASH */
const defaultApiBackend = require('./api.js');
import defaultApiBackend from './api.js';
module.exports = (options) => {
export default (options) => {
const isMobile = /mobile/i.test(window.navigator.userAgent);
// compatibility: some mobile browsers don't suppose autoplay
if (isMobile) {

View File

@ -130,4 +130,4 @@ class Setting {
}
}
module.exports = Setting;
export default Setting;

View File

@ -52,4 +52,4 @@ class Subtitle {
}
}
module.exports = Subtitle;
export default Subtitle;

View File

@ -21,4 +21,4 @@ class SvgSource {
}
}
module.exports = SvgSource;
export default SvgSource;

View File

@ -341,4 +341,4 @@ class Template {
}
}
module.exports = Template;
export default Template;

View File

@ -29,4 +29,4 @@ class Thumbnails {
}
}
module.exports = Thumbnails;
export default Thumbnails;

View File

@ -100,4 +100,4 @@ class Time {
}
}
module.exports = Time;
export default Time;

View File

@ -38,4 +38,4 @@ class User {
}
}
module.exports = User;
export default User;

View File

@ -1,4 +1,4 @@
module.exports = {
export default {
/**
* Parse second to 00:00 format

View File

@ -9,7 +9,7 @@ module.exports = {
devtool: 'cheap-module-source-map',
entry: {
'DPlayer': './src/index.js'
'DPlayer': './src/js/index.js'
},
output: {
@ -17,6 +17,7 @@ module.exports = {
filename: '[name].js',
library: '[name]',
libraryTarget: 'umd',
libraryExport: 'default',
umdNamedDefine: true,
publicPath: '/'
},
@ -33,7 +34,7 @@ module.exports = {
test: /\.js$/,
enforce: 'pre',
loader: require.resolve('eslint-loader'),
include: path.resolve(__dirname, '../src'),
include: path.resolve(__dirname, '../src/js'),
},
{
test: /\.js$/,

View File

@ -12,7 +12,7 @@ module.exports = {
devtool: 'source-map',
entry: {
'DPlayer': './src/index.js'
'DPlayer': './src/js/index.js'
},
output: {
@ -20,6 +20,7 @@ module.exports = {
filename: '[name].min.js',
library: '[name]',
libraryTarget: 'umd',
libraryExport: 'default',
umdNamedDefine: true,
publicPath: '/'
},
@ -36,7 +37,7 @@ module.exports = {
test: /\.js$/,
enforce: 'pre',
loader: require.resolve('eslint-loader'),
include: path.resolve(__dirname, '../src'),
include: path.resolve(__dirname, '../src/js'),
},
{
test: /\.js$/,