350 open graph react #360
|
@ -30,17 +30,6 @@ sequelize
|
||||||
logger.error('Sequelize was unable to connect to the database:', err);
|
logger.error('Sequelize was unable to connect to the database:', err);
|
||||||
});
|
});
|
||||||
|
|
||||||
// // add each model to the db object
|
|
||||||
// fs
|
|
||||||
// .readdirSync(__dirname)
|
|
||||||
// .filter(file => {
|
|
||||||
// return (file.indexOf('.') !== 0 && file !== basename && file.slice(-3) === '.js');
|
|
||||||
// })
|
|
||||||
// .forEach(file => {
|
|
||||||
// const model = sequelize['import'](path.join(__dirname, file));
|
|
||||||
// db[model.name] = model;
|
|
||||||
// });
|
|
||||||
|
|
||||||
// manually add each model to the db
|
// manually add each model to the db
|
||||||
const Certificate = require('./certificate.js');
|
const Certificate = require('./certificate.js');
|
||||||
const Channel = require('./channel.js');
|
const Channel = require('./channel.js');
|
||||||
|
|
|
@ -6,12 +6,13 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "mocha --recursive",
|
"test": "mocha --recursive",
|
||||||
"test-all": "mocha --recursive",
|
"test-all": "mocha --recursive",
|
||||||
"start": "nodemon server.js",
|
"start": "server.js",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"fix": "eslint . --fix",
|
"fix": "eslint . --fix",
|
||||||
"precommit": "eslint .",
|
"precommit": "eslint .",
|
||||||
"babel": "babel",
|
"babel": "babel",
|
||||||
"webpack": "webpack"
|
"build-dev": "webpack",
|
||||||
|
"build-production": "webpack"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -89,6 +90,7 @@
|
||||||
"nodemon": "^1.15.1",
|
"nodemon": "^1.15.1",
|
||||||
"redux-devtools": "^3.4.1",
|
"redux-devtools": "^3.4.1",
|
||||||
"regenerator-transform": "^0.12.3",
|
"regenerator-transform": "^0.12.3",
|
||||||
"webpack": "^3.10.0"
|
"webpack": "^3.10.0",
|
||||||
|
"webpack-merge": "^4.1.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,8 @@ const reduxMiddleware = window.__REDUX_DEVTOOLS_EXTENSION__ ? compose(middleware
|
||||||
Probably don't need these Probably don't need these `console.log`s here.
|
|||||||
// create teh store
|
// create teh store
|
||||||
let store;
|
let store;
|
||||||
if (preloadedState) {
|
if (preloadedState) {
|
||||||
console.log('initial load: preloaded state found');
|
|
||||||
Probably don't need these Probably don't need these `console.log`s here.
|
|||||||
store = createStore(Reducer, preloadedState, reduxMiddleware);
|
store = createStore(Reducer, preloadedState, reduxMiddleware);
|
||||||
} else {
|
} else {
|
||||||
console.log('initial load: no preloaded state found');
|
|
||||||
Probably don't need these Probably don't need these `console.log`s here.
|
|||||||
store = createStore(Reducer, reduxMiddleware);
|
store = createStore(Reducer, reduxMiddleware);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Probably don't need these Probably don't need these `console.log`s here.
Probably don't need these Probably don't need these `console.log`s here.
|
|
@ -1,21 +0,0 @@
|
||||||
I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the Then you wouldn't have to worry about the I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the `show` reducer here, which I don't really think needs to exist (in the future).
Then you wouldn't have to worry about the `show` reducer being populated and could use these tags for other pages (not sure if you would ever need to do that though)
ah, yes. This component should actually be deleted. I made it before moving everything into the ah, yes. This component should actually be deleted. I made it before moving everything into the `<SEO />` component.
I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the Then you wouldn't have to worry about the I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the `show` reducer here, which I don't really think needs to exist (in the future).
Then you wouldn't have to worry about the `show` reducer being populated and could use these tags for other pages (not sure if you would ever need to do that though)
ah, yes. This component should actually be deleted. I made it before moving everything into the ah, yes. This component should actually be deleted. I made it before moving everything into the `<SEO />` component.
|
|||||||
import { connect } from 'react-redux';
|
|
||||||
I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the Then you wouldn't have to worry about the I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the `show` reducer here, which I don't really think needs to exist (in the future).
Then you wouldn't have to worry about the `show` reducer being populated and could use these tags for other pages (not sure if you would ever need to do that though)
ah, yes. This component should actually be deleted. I made it before moving everything into the ah, yes. This component should actually be deleted. I made it before moving everything into the `<SEO />` component.
|
|||||||
import View from './view';
|
|
||||||
I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the Then you wouldn't have to worry about the I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the `show` reducer here, which I don't really think needs to exist (in the future).
Then you wouldn't have to worry about the `show` reducer being populated and could use these tags for other pages (not sure if you would ever need to do that though)
ah, yes. This component should actually be deleted. I made it before moving everything into the ah, yes. This component should actually be deleted. I made it before moving everything into the `<SEO />` component.
|
|||||||
|
|
||||||
I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the Then you wouldn't have to worry about the I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the `show` reducer here, which I don't really think needs to exist (in the future).
Then you wouldn't have to worry about the `show` reducer being populated and could use these tags for other pages (not sure if you would ever need to do that though)
ah, yes. This component should actually be deleted. I made it before moving everything into the ah, yes. This component should actually be deleted. I made it before moving everything into the `<SEO />` component.
|
|||||||
const mapStateToProps = ({ show }) => {
|
|
||||||
I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the Then you wouldn't have to worry about the I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the `show` reducer here, which I don't really think needs to exist (in the future).
Then you wouldn't have to worry about the `show` reducer being populated and could use these tags for other pages (not sure if you would ever need to do that though)
ah, yes. This component should actually be deleted. I made it before moving everything into the ah, yes. This component should actually be deleted. I made it before moving everything into the `<SEO />` component.
|
|||||||
// select request info
|
|
||||||
I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the Then you wouldn't have to worry about the I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the `show` reducer here, which I don't really think needs to exist (in the future).
Then you wouldn't have to worry about the `show` reducer being populated and could use these tags for other pages (not sure if you would ever need to do that though)
ah, yes. This component should actually be deleted. I made it before moving everything into the ah, yes. This component should actually be deleted. I made it before moving everything into the `<SEO />` component.
|
|||||||
const requestId = show.request.id;
|
|
||||||
I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the Then you wouldn't have to worry about the I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the `show` reducer here, which I don't really think needs to exist (in the future).
Then you wouldn't have to worry about the `show` reducer being populated and could use these tags for other pages (not sure if you would ever need to do that though)
ah, yes. This component should actually be deleted. I made it before moving everything into the ah, yes. This component should actually be deleted. I made it before moving everything into the `<SEO />` component.
|
|||||||
// select asset info
|
|
||||||
I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the Then you wouldn't have to worry about the I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the `show` reducer here, which I don't really think needs to exist (in the future).
Then you wouldn't have to worry about the `show` reducer being populated and could use these tags for other pages (not sure if you would ever need to do that though)
ah, yes. This component should actually be deleted. I made it before moving everything into the ah, yes. This component should actually be deleted. I made it before moving everything into the `<SEO />` component.
|
|||||||
let asset;
|
|
||||||
I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the Then you wouldn't have to worry about the I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the `show` reducer here, which I don't really think needs to exist (in the future).
Then you wouldn't have to worry about the `show` reducer being populated and could use these tags for other pages (not sure if you would ever need to do that though)
ah, yes. This component should actually be deleted. I made it before moving everything into the ah, yes. This component should actually be deleted. I made it before moving everything into the `<SEO />` component.
|
|||||||
const request = show.requestList[requestId] || null;
|
|
||||||
I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the Then you wouldn't have to worry about the I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the `show` reducer here, which I don't really think needs to exist (in the future).
Then you wouldn't have to worry about the `show` reducer being populated and could use these tags for other pages (not sure if you would ever need to do that though)
ah, yes. This component should actually be deleted. I made it before moving everything into the ah, yes. This component should actually be deleted. I made it before moving everything into the `<SEO />` component.
|
|||||||
const assetList = show.assetList;
|
|
||||||
I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the Then you wouldn't have to worry about the I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the `show` reducer here, which I don't really think needs to exist (in the future).
Then you wouldn't have to worry about the `show` reducer being populated and could use these tags for other pages (not sure if you would ever need to do that though)
ah, yes. This component should actually be deleted. I made it before moving everything into the ah, yes. This component should actually be deleted. I made it before moving everything into the `<SEO />` component.
|
|||||||
if (request && assetList) {
|
|
||||||
I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the Then you wouldn't have to worry about the I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the `show` reducer here, which I don't really think needs to exist (in the future).
Then you wouldn't have to worry about the `show` reducer being populated and could use these tags for other pages (not sure if you would ever need to do that though)
ah, yes. This component should actually be deleted. I made it before moving everything into the ah, yes. This component should actually be deleted. I made it before moving everything into the `<SEO />` component.
|
|||||||
const assetKey = request.key; // note: just store this in the request
|
|
||||||
I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the Then you wouldn't have to worry about the I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the `show` reducer here, which I don't really think needs to exist (in the future).
Then you wouldn't have to worry about the `show` reducer being populated and could use these tags for other pages (not sure if you would ever need to do that though)
ah, yes. This component should actually be deleted. I made it before moving everything into the ah, yes. This component should actually be deleted. I made it before moving everything into the `<SEO />` component.
|
|||||||
asset = assetList[assetKey] || null;
|
|
||||||
I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the Then you wouldn't have to worry about the I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the `show` reducer here, which I don't really think needs to exist (in the future).
Then you wouldn't have to worry about the `show` reducer being populated and could use these tags for other pages (not sure if you would ever need to do that though)
ah, yes. This component should actually be deleted. I made it before moving everything into the ah, yes. This component should actually be deleted. I made it before moving everything into the `<SEO />` component.
|
|||||||
};
|
|
||||||
I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the Then you wouldn't have to worry about the I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the `show` reducer here, which I don't really think needs to exist (in the future).
Then you wouldn't have to worry about the `show` reducer being populated and could use these tags for other pages (not sure if you would ever need to do that though)
ah, yes. This component should actually be deleted. I made it before moving everything into the ah, yes. This component should actually be deleted. I made it before moving everything into the `<SEO />` component.
|
|||||||
// return props
|
|
||||||
I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the Then you wouldn't have to worry about the I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the `show` reducer here, which I don't really think needs to exist (in the future).
Then you wouldn't have to worry about the `show` reducer being populated and could use these tags for other pages (not sure if you would ever need to do that though)
ah, yes. This component should actually be deleted. I made it before moving everything into the ah, yes. This component should actually be deleted. I made it before moving everything into the `<SEO />` component.
|
|||||||
return {
|
|
||||||
I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the Then you wouldn't have to worry about the I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the `show` reducer here, which I don't really think needs to exist (in the future).
Then you wouldn't have to worry about the `show` reducer being populated and could use these tags for other pages (not sure if you would ever need to do that though)
ah, yes. This component should actually be deleted. I made it before moving everything into the ah, yes. This component should actually be deleted. I made it before moving everything into the `<SEO />` component.
|
|||||||
asset,
|
|
||||||
I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the Then you wouldn't have to worry about the I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the `show` reducer here, which I don't really think needs to exist (in the future).
Then you wouldn't have to worry about the `show` reducer being populated and could use these tags for other pages (not sure if you would ever need to do that though)
ah, yes. This component should actually be deleted. I made it before moving everything into the ah, yes. This component should actually be deleted. I made it before moving everything into the `<SEO />` component.
|
|||||||
};
|
|
||||||
I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the Then you wouldn't have to worry about the I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the `show` reducer here, which I don't really think needs to exist (in the future).
Then you wouldn't have to worry about the `show` reducer being populated and could use these tags for other pages (not sure if you would ever need to do that though)
ah, yes. This component should actually be deleted. I made it before moving everything into the ah, yes. This component should actually be deleted. I made it before moving everything into the `<SEO />` component.
|
|||||||
};
|
|
||||||
I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the Then you wouldn't have to worry about the I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the `show` reducer here, which I don't really think needs to exist (in the future).
Then you wouldn't have to worry about the `show` reducer being populated and could use these tags for other pages (not sure if you would ever need to do that though)
ah, yes. This component should actually be deleted. I made it before moving everything into the ah, yes. This component should actually be deleted. I made it before moving everything into the `<SEO />` component.
|
|||||||
|
|
||||||
I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the Then you wouldn't have to worry about the I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the `show` reducer here, which I don't really think needs to exist (in the future).
Then you wouldn't have to worry about the `show` reducer being populated and could use these tags for other pages (not sure if you would ever need to do that though)
ah, yes. This component should actually be deleted. I made it before moving everything into the ah, yes. This component should actually be deleted. I made it before moving everything into the `<SEO />` component.
|
|||||||
export default connect(mapStateToProps, null)(View);
|
|
||||||
I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the Then you wouldn't have to worry about the I'm probably missing something here, but wherever this is rendered, don't you already have the asset? You could just directly pass it in (or just pass some identifier to easily find it in state). Then you wouldn't need the `show` reducer here, which I don't really think needs to exist (in the future).
Then you wouldn't have to worry about the `show` reducer being populated and could use these tags for other pages (not sure if you would ever need to do that though)
ah, yes. This component should actually be deleted. I made it before moving everything into the ah, yes. This component should actually be deleted. I made it before moving everything into the `<SEO />` component.
|
|
@ -1,83 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import Helmet from 'react-helmet';
|
|
||||||
|
|
||||||
const { site: { title, host }, claim: { defaultThumbnail, defaultDescription } } = require('../../../config/speechConfig.js');
|
|
||||||
|
|
||||||
const determineOgThumbnailContentType = (thumbnail) => {
|
|
||||||
if (thumbnail) {
|
|
||||||
const fileExt = thumbnail.substring(thumbnail.lastIndexOf('.'));
|
|
||||||
switch (fileExt) {
|
|
||||||
case 'jpeg':
|
|
||||||
case 'jpg':
|
|
||||||
return 'image/jpeg';
|
|
||||||
case 'png':
|
|
||||||
return 'image/png';
|
|
||||||
case 'gif':
|
|
||||||
return 'image/gif';
|
|
||||||
case 'mp4':
|
|
||||||
return 'video/mp4';
|
|
||||||
default:
|
|
||||||
return 'image/jpeg';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpenGraphTags extends React.Component {
|
|
||||||
render () {
|
|
||||||
const { claimData } = this.props.asset;
|
|
||||||
const { contentType } = claimData;
|
|
||||||
const embedUrl = `${host}/${claimData.claimId}/${claimData.name}`;
|
|
||||||
const showUrl = `${host}/${claimData.claimId}/${claimData.name}`;
|
|
||||||
const source = `${host}/${claimData.claimId}/${claimData.name}.${claimData.fileExt}`;
|
|
||||||
const ogTitle = claimData.title || claimData.name;
|
|
||||||
const ogDescription = claimData.description || defaultDescription;
|
|
||||||
const ogThumbnailContentType = determineOgThumbnailContentType(claimData.thumbnail);
|
|
||||||
const ogThumbnail = claimData.thumbnail || defaultThumbnail;
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<Helmet>
|
|
||||||
{/* basic open graph tags */}
|
|
||||||
<meta property='og:title' content={ogTitle} />
|
|
||||||
<meta property='og:url' content={showUrl} />
|
|
||||||
<meta property='og:site_name' content={title} />
|
|
||||||
<meta property='og:description' content={ogDescription} />
|
|
||||||
<meta property='og:image:width' content='600' />
|
|
||||||
<meta property='og:image:height' content='315' />
|
|
||||||
{/* basic twitter tags */}
|
|
||||||
<meta name='twitter:site' content='@spee_ch' />
|
|
||||||
</Helmet>
|
|
||||||
{ contentType === 'video/mp4' || contentType === 'video/webm' ? (
|
|
||||||
<Helmet>
|
|
||||||
{/* video open graph tags */}
|
|
||||||
<meta property='og:video' content={source} />
|
|
||||||
<meta property='og:video:secure_url' content={source} />
|
|
||||||
<meta property='og:video:type' content={contentType} />
|
|
||||||
<meta property='og:image' content={ogThumbnail} />
|
|
||||||
<meta property='og:image:type' content={ogThumbnailContentType} />
|
|
||||||
<meta property='og:type' content='video' />
|
|
||||||
{/* video twitter tags */}
|
|
||||||
<meta name='twitter:card' content='player' />
|
|
||||||
<meta name='twitter:player' content={embedUrl} />
|
|
||||||
<meta name='twitter:player:width' content='600' />
|
|
||||||
<meta name='twitter:text:player_width' content='600' />
|
|
||||||
<meta name='twitter:player:height' content='337' />
|
|
||||||
<meta name='twitter:player:stream' content={source} />
|
|
||||||
<meta name='twitter:player:stream:content_type' content={contentType} />
|
|
||||||
</Helmet>
|
|
||||||
) : (
|
|
||||||
<Helmet>
|
|
||||||
{/* image open graph tags */}
|
|
||||||
<meta property='og:image' content={source} />
|
|
||||||
<meta property='og:image:type' content={contentType} />
|
|
||||||
<meta property='og:type' content='article' />
|
|
||||||
{/* image twitter tags */}
|
|
||||||
<meta name='twitter:card' content='summary_large_image' />
|
|
||||||
</Helmet>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default OpenGraphTags;
|
|
|
@ -1,76 +1,91 @@
|
||||||
const Path = require('path');
|
const Path = require('path');
|
||||||
I would recommend creating separate webpack configs for dev/prod. Before we did our big restructure changes the apps webpack setup had three files: A base config: contains the generic stuff like babel, entry/output points, css loader, etc.
I would recommend creating separate webpack configs for dev/prod. Before we did our big restructure changes the apps webpack setup had three files:
A base config: contains the generic stuff like babel, entry/output points, css loader, etc.
A dev config which extends the base config: contains stuff like `watch: true` (not needed in prod) and source maps
A prod config which extends the base config: contains stuff like minification (that's the main thing)
`webpack-merge` is a great tool for this
https://github.com/survivejs/webpack-merge
|
|||||||
const nodeExternals = require('webpack-node-externals');
|
const nodeExternals = require('webpack-node-externals');
|
||||||
const REACT_ROOT = Path.resolve(__dirname, 'react/');
|
const REACT_ROOT = Path.resolve(__dirname, 'react/');
|
||||||
|
const merge = require('webpack-merge');
|
||||||
|
const TARGET = process.env.npm_lifecycle_event;
|
||||||
|
|
||||||
console.log('REACT_ROOT:', REACT_ROOT);
|
const serverBaseConfig = {
|
||||||
|
target: 'node',
|
||||||
|
node : {
|
||||||
|
__dirname: false,
|
||||||
|
},
|
||||||
|
externals: [nodeExternals()],
|
||||||
|
entry : ['babel-polyfill', 'whatwg-fetch', './index.js'],
|
||||||
|
output : {
|
||||||
|
path : Path.resolve(__dirname),
|
||||||
|
publicPath: '/',
|
||||||
|
filename : 'server.js',
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test : /.jsx?$/,
|
||||||
|
exclude: /node_modules/,
|
||||||
|
loader : 'babel-loader',
|
||||||
|
options: {
|
||||||
|
presets: ['es2015', 'react', 'stage-2'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test : /.css$/,
|
||||||
|
loader: 'css-loader',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
modules: [
|
||||||
|
REACT_ROOT,
|
||||||
|
'node_modules',
|
||||||
|
__dirname,
|
||||||
|
],
|
||||||
|
extensions: ['.js', '.json', '.jsx', '.css'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = [
|
const clientBaseConfig = {
|
||||||
{
|
target: 'web',
|
||||||
target: 'web',
|
entry : ['babel-polyfill', 'whatwg-fetch', './react/client.js'],
|
||||||
entry : ['babel-polyfill', 'whatwg-fetch', './react/client.js'],
|
output: {
|
||||||
output: {
|
path : Path.join(__dirname, 'public/bundle/'),
|
||||||
path : Path.join(__dirname, 'public/bundle/'),
|
publicPath: 'public/bundle/',
|
||||||
publicPath: 'public/bundle/',
|
filename : 'bundle.js',
|
||||||
filename : 'bundle.js',
|
|
||||||
},
|
|
||||||
watch : true,
|
|
||||||
module: {
|
|
||||||
loaders: [
|
|
||||||
{
|
|
||||||
test : /.jsx?$/,
|
|
||||||
loader : 'babel-loader',
|
|
||||||
exclude: /node_modules/,
|
|
||||||
query : {
|
|
||||||
presets: ['es2015', 'react', 'stage-2'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
modules: [
|
|
||||||
REACT_ROOT,
|
|
||||||
'node_modules',
|
|
||||||
__dirname,
|
|
||||||
],
|
|
||||||
extensions: ['.js', '.jsx', '.scss'],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
module: {
|
||||||
target: 'node',
|
loaders: [
|
||||||
node : {
|
{
|
||||||
__dirname: false,
|
test : /.jsx?$/,
|
||||||
},
|
loader : 'babel-loader',
|
||||||
externals: [nodeExternals()],
|
exclude: /node_modules/,
|
||||||
entry : ['babel-polyfill', 'whatwg-fetch', './index.js'],
|
query : {
|
||||||
output : {
|
presets: ['es2015', 'react', 'stage-2'],
|
||||||
path : Path.resolve(__dirname),
|
|
||||||
publicPath: '/',
|
|
||||||
filename : 'server.js',
|
|
||||||
},
|
|
||||||
watch : true,
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test : /.jsx?$/,
|
|
||||||
exclude: /node_modules/,
|
|
||||||
loader : 'babel-loader',
|
|
||||||
options: {
|
|
||||||
presets: ['es2015', 'react', 'stage-2'],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
},
|
||||||
test : /.css$/,
|
],
|
||||||
loader: 'css-loader',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
modules: [
|
|
||||||
REACT_ROOT,
|
|
||||||
'node_modules',
|
|
||||||
__dirname,
|
|
||||||
],
|
|
||||||
extensions: ['.js', '.json', '.jsx', '.css'],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
];
|
resolve: {
|
||||||
|
modules: [
|
||||||
|
REACT_ROOT,
|
||||||
|
'node_modules',
|
||||||
|
__dirname,
|
||||||
|
],
|
||||||
|
extensions: ['.js', '.jsx', '.scss'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
if (TARGET === 'build-dev') {
|
||||||
|
module.exports = [
|
||||||
|
merge(serverBaseConfig, {
|
||||||
|
watch: true,
|
||||||
|
}),
|
||||||
|
merge(clientBaseConfig, {
|
||||||
|
watch: true,
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
if (TARGET === 'build-production') {
|
||||||
|
module.exports = [
|
||||||
|
merge(clientBaseConfig, {}),
|
||||||
|
merge(serverBaseConfig, {}),
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
Probably don't need these
console.log
s here.