Skip to content

Commit

Permalink
Refactor development setup
Browse files Browse the repository at this point in the history
  • Loading branch information
cookpete committed Sep 8, 2017
1 parent ad751d1 commit 81df2a8
Show file tree
Hide file tree
Showing 20 changed files with 2,055 additions and 1,216 deletions.
14 changes: 0 additions & 14 deletions .babelrc

This file was deleted.

4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
language: node_js
dist: trusty
addons:
apt:
packages:
Expand All @@ -8,9 +7,6 @@ before_install:
- export CHROME_BIN=chromium-browser
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
install:
- npm install -g npm@4
- npm install
node_js:
- 6
script:
Expand Down
5 changes: 2 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@
"test",
"src",
"lib",
"server.js",
"index.html",
"webpack.config.*.js"
"webpack.*.js"
],
"dependencies": {
"react": "^0.14.7"
"react": "*"
}
}
2 changes: 0 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>ReactPlayer Demo</title>
<link href='app.css' rel='stylesheet'>
</head>
<body>
<div id='app'></div>
<script src='app.js'></script>
</body>
</html>
38 changes: 26 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
"typings": "index.d.ts",
"scripts": {
"clean": "rimraf lib demo",
"build:webpack": "cross-env NODE_ENV=production webpack --config webpack.config.prod.js",
"build:browser": "cross-env NODE_ENV=production webpack --config webpack.config.browser.js",
"build:demo": "npm run clean && npm run build:webpack && cp index.html demo",
"build:demo": "cross-env NODE_ENV=production webpack --config webpack.production.babel.js",
"build:browser": "cross-env NODE_ENV=production webpack --config webpack.browser.babel.js",
"build:compile": "cross-env NODE_ENV=production babel src -d lib --ignore src/demo",
"start": "node server.js",
"start": "webpack-dev-server",
"lint": "standard --verbose | snazzy",
"test": "karma start test/karma.config.js",
"test": "babel-node ./node_modules/karma/bin/karma start test/karma.config.js",
"preversion": "npm run lint",
"version": "npm run update-changelog && npm run build:browser && git add CHANGELOG.md dist",
"update-changelog": "auto-changelog --package --template compact",
Expand Down Expand Up @@ -47,7 +46,7 @@
},
"devDependencies": {
"auto-changelog": "^0.3.1",
"babel-cli": "^6.16.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.16.0",
"babel-eslint": "^7.0.0",
"babel-loader": "^7.0.0",
Expand All @@ -56,16 +55,14 @@
"babel-plugin-transform-es3-property-literals": "^6.8.0",
"babel-preset-es2015": "^6.16.0",
"babel-preset-react": "^6.16.0",
"babel-preset-react-hmre": "^1.1.1",
"babel-preset-stage-0": "^6.16.0",
"chai": "^4.0.2",
"cross-env": "^5.0.1",
"css-loader": "^0.28.0",
"es6-promise": "^4.0.3",
"exports-loader": "^0.6.3",
"express": "^4.14.0",
"extract-text-webpack-plugin": "^3.0.0",
"json-loader": "^0.5.4",
"html-webpack-plugin": "^2.30.1",
"karma": "^1.3.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.0.0",
Expand All @@ -77,18 +74,17 @@
"karma-webpack": "^2.0.2",
"mocha": "^3.1.0",
"node-sass": "^4.1.1",
"normalize.css": "^7.0.0",
"react": "^15.3.2",
"react-dom": "^15.3.2",
"react-hot-loader": "3.0.0-beta.7",
"rimraf": "^2.5.4",
"sass-loader": "^6.0.1",
"screenfull": "^3.0.2",
"snazzy": "^7.0.0",
"standard": "^10.0.0",
"style-loader": "^0.18.2",
"webpack": "^3.3.0",
"webpack-dev-middleware": "^1.8.3",
"webpack-hot-middleware": "^2.12.2",
"webpack-dev-server": "^2.7.1",
"whatwg-fetch": "^2.0.1"
},
"dependencies": {
Expand All @@ -97,6 +93,24 @@
"lodash.omit": "^4.5.0",
"prop-types": "^15.5.6"
},
"babel": {
"presets": [
"es2015",
"stage-0",
"react"
],
"plugins": [
"react-hot-loader/babel"
],
"env": {
"production": {
"plugins": [
"transform-es3-member-expression-literals",
"transform-es3-property-literals"
]
}
}
},
"standard": {
"parser": "babel-eslint",
"ignore": [
Expand Down
27 changes: 0 additions & 27 deletions server.js

This file was deleted.

6 changes: 3 additions & 3 deletions src/demo/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component } from 'react'
import { findDOMNode } from 'react-dom'
import screenfull from 'screenfull'

import 'normalize.css/normalize.css'
import './reset.scss'
import './defaults.scss'
import './App.scss'
import './Range.scss'
Expand Down Expand Up @@ -120,8 +120,8 @@ export default class App extends Component {
fileConfig={fileConfig}
onReady={() => console.log('onReady')}
onStart={() => console.log('onStart')}
onPlay={() => this.setState({ playing: true })}
onPause={() => this.setState({ playing: false })}
// onPlay={() => this.setState({ playing: true })}
// onPause={() => this.setState({ playing: false })}
onBuffer={() => console.log('onBuffer')}
onSeek={e => console.log('onSeek', e)}
onEnded={() => this.setState({ playing: false })}
Expand Down
2 changes: 1 addition & 1 deletion src/demo/App.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$black: #000;
$column-width: 480px;
$gutter-width: 10px;
$gutter-width: 20px;
// $break: $column-width * 2 + $gutter-width * 3;

.app {
Expand Down
4 changes: 4 additions & 0 deletions src/demo/defaults.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ h1,
h2,
h3 {
font-weight: 300;
margin-bottom: 1em;
}

h1 { font-size: 20px; }
h2 { font-size: 16px; margin-top: 1em; }

table,
progress {
width: 100%;
Expand Down
15 changes: 12 additions & 3 deletions src/demo/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import React from 'react'
import ReactDOM from 'react-dom'

import { render } from 'react-dom'
import { AppContainer } from 'react-hot-loader'
import App from './App'

ReactDOM.render(<App />, document.getElementById('app'))
const app = document.getElementById('app')

render(<AppContainer><App /></AppContainer>, app)

if (module.hot) {
module.hot.accept('./App', () => {
const NextApp = require('./App').default
render(<AppContainer><NextApp /></AppContainer>, app)
})
}
48 changes: 48 additions & 0 deletions src/demo/reset.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
10 changes: 6 additions & 4 deletions test/karma.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
var webpackConfig = require('../webpack.config.dev')
webpackConfig.devtool = 'inline-source-map'
import webpackConfig from '../webpack.config.babel'

module.exports = function (config) {
export default function (config) {
config.set({
browsers: process.env.TRAVIS ? [ 'ChromeTravis' ] : [ 'Chrome', 'Firefox' ],
singleRun: true,
Expand All @@ -13,7 +12,10 @@ module.exports = function (config) {
'karma.webpack.js': [ 'webpack', 'sourcemap' ]
},
reporters: [ 'mocha' ],
webpack: webpackConfig,
webpack: {
...webpackConfig,
devtool: 'inline-source-map'
},
webpackServer: {
noInfo: true
},
Expand Down
2 changes: 1 addition & 1 deletion test/karma.webpack.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
var context = require.context('./karma', true, /\.js$/)
const context = require.context('./karma', true, /\.js$/)
context.keys().forEach(context)
34 changes: 34 additions & 0 deletions webpack.browser.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import path from 'path'
import webpack from 'webpack'
import config, { minifyPlugins } from './webpack.production.babel'

export default {
...config,
entry: './src/ReactPlayer',
output: {
path: path.join(__dirname, 'dist'),
filename: 'ReactPlayer.js',
library: 'ReactPlayer'
},
externals: {
'react': 'React'
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
options: {
plugins: ['add-module-exports']
}
}
]
},
plugins: [
new webpack.ProvidePlugin({
'Promise': 'exports-loader?global.Promise!es6-promise',
'window.fetch': 'exports-loader?self.fetch!whatwg-fetch'
}),
...minifyPlugins
]
}

0 comments on commit 81df2a8

Please sign in to comment.