SIGN IN SIGN UP
cookpete / react-player UNCLAIMED

A React component for playing a variety of URLs, including file paths, YouTube, Facebook, Twitch, SoundCloud, Streamable, Vimeo, Wistia and DailyMotion

0 0 67 TypeScript
2017-09-08 14:28:21 +01:00
import { join } from 'path'
import webpack from 'webpack'
import { extract } from 'extract-text-webpack-plugin'
import HtmlWebpackPlugin from 'html-webpack-plugin'
const PORT = 3000
const PRODUCTION = process.env.NODE_ENV === 'production'
const PUBLIC_PATH = PRODUCTION ? '' : `http://localhost:${PORT}/`
2017-09-08 14:28:21 +01:00
const PATH_DEMO = join(__dirname, 'demo')
const PATH_SRC = join(__dirname, 'src')
const PATH_INDEX = join(__dirname, 'index.html')
2017-09-12 11:06:37 +01:00
const PATH_TESTS = join(__dirname, 'test', 'specs')
2017-09-08 14:28:21 +01:00
export const plugins = [
new HtmlWebpackPlugin({
template: PATH_INDEX,
minify: {
collapseWhitespace: true,
quoteCharacter: '\''
}
})
]
export default {
devtool: 'cheap-module-eval-source-map',
entry: [
`webpack-dev-server/client?http://localhost:${PORT}`,
'webpack/hot/only-dev-server',
'./src/demo/index'
],
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
include: [ PATH_SRC, PATH_TESTS ]
},
{
test: /\.css$/,
2017-09-08 14:28:21 +01:00
use: styleLoader([
'style-loader',
'css-loader?sourceMap',
'postcss-loader?sourceMap'
2017-09-08 14:28:21 +01:00
]),
include: PATH_SRC
}
]
},
output: {
path: PATH_DEMO,
filename: 'app.js',
publicPath: PUBLIC_PATH
},
plugins: [
...plugins,
new webpack.HotModuleReplacementPlugin(),
2017-09-09 01:05:34 +01:00
new webpack.NoEmitOnErrorsPlugin(),
new webpack.NamedModulesPlugin()
2017-09-08 14:28:21 +01:00
],
devServer: {
port: PORT,
publicPath: PUBLIC_PATH,
hot: true,
historyApiFallback: true,
stats: {
colors: true
}
}
}
function styleLoader (loaders) {
if (process.env.NODE_ENV === 'production') {
const [ fallback, ...use ] = loaders
return extract({ fallback, use })
}
return loaders
}