Skip to content

Instantly share code, notes, and snippets.

@anilGupta
Created January 12, 2016 10:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anilGupta/31888417a0eb0fdad7bc to your computer and use it in GitHub Desktop.
Save anilGupta/31888417a0eb0fdad7bc to your computer and use it in GitHub Desktop.
//webpack.config.js
const config = {
externals: {
'window': 'Window'
},
resolve: {
extensions: ['', '.webpack.js', '.web.js', '.js', '.jsx', '.json'],
alias: {
'jwplayer': path.join(__dirname, '../src/components/VideoPage/lib/jwplayer.js')
}
},
module: {
loaders: [
{
test: /\.jsx?$/,
include: [
path.resolve(__dirname, '../node_modules/react-routing/src'),
path.resolve(__dirname, '../src'),
],
loader: 'babel-loader',
},
{
test: /\.scss$/,
loaders: [
'isomorphic-style-loader',
'css-loader?' + (DEBUG ? 'sourceMap&' : 'minimize&') +
'modules&localIdentName=[name]_[local]_[hash:base64:3]',
'postcss-loader',
],
}, {
test: /\.json$/,
loader: 'json-loader',
}, {
test: /\.txt$/,
loader: 'raw-loader',
}, {
test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|eot|ttf)(\?.*$|$)/,
loader: 'url-loader?limit=10000',
}, {
test: /\.(eot|ttf|wav|mp3)$/,
loader: 'file-loader',
},
{
test: /jwplayer.js$/,
loader: 'expose?jwplayer'
}
],
}
};
//my react component VideoPage.js
import React, { Component, PropTypes } from 'react';
import s from './LoginPage.scss';
import withStyles from '../../decorators/withStyles';
import jwplayer from 'jwplayer'
@withStyles(s)
class VideoPage extends Component {
componentWillMount() {
console.log(jwplayer);
}
render() {
return (
<div className={s.root}>
</div>
);
}
}
export default VideoPage;
@anilGupta
Copy link
Author

i am getting following error

webpack: bundle is now VALID.
Error: Cannot find module 'jwplayer'
    at Function.Module._resolveFilename (module.js:326:15)
    at Function.Module._load (module.js:277:25)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (C:\wamp\www\test\build\webpack:\external "jwplayer":1:1)
    at __webpack_require__ (C:\wamp\www\test\build\webpack:\webpack\bootstrap 34ca5b6f5a4ade87fe6c:19:1)
    at Object.<anonymous> (C:\wamp\www\test\build\webpack:\C:\wamp\www\test\src\components\LoginPage\LoginPage.js:4:53)
    at __webpack_require__ (C:\wamp\www\test\build\webpack:\webpack\bootstrap 34ca5b6f5a4ade87fe6c:19:1)
    at Object.module.exports.Object.defineProperty.value (C:\wamp\www\test\build\webpack:\C:\wamp\www\test\src\routes.js:15:51)
    at __webpack_require__ (C:\wamp\www\test\build\webpack:\webpack\bootstrap 34ca5b6f5a4ade87fe6c:19:1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment