Speech as a package #416

Merged
bones7242 merged 89 commits from speech-as-a-package into master 2018-04-18 21:47:34 +02:00
12 changed files with 12242 additions and 12209 deletions
Showing only changes of commit 6c2415c11b - Show all commits

View file

@ -1,4 +1,4 @@
node_modules/
public/bundle
exports/
index.js
test
test/

View file

@ -6,10 +6,11 @@ import { BrowserRouter } from 'react-router-dom';
import Reducer from 'reducers';
import createSagaMiddleware from 'redux-saga';
import rootSaga from 'sagas';
import GAListener from 'components/GAListener';
import App from './app';
const siteConfig = require('siteConfig.js');
// get the state from a global variable injected into the server-generated HTML
const preloadedState = window.__PRELOADED_STATE__ || null;
@ -21,7 +22,7 @@ const sagaMiddleware = createSagaMiddleware();
const middleware = applyMiddleware(sagaMiddleware);
const reduxMiddleware = window.__REDUX_DEVTOOLS_EXTENSION__ ? compose(middleware, window.__REDUX_DEVTOOLS_EXTENSION__()) : middleware;
// create teh store
// create the store
let store;
if (preloadedState) {
store = createStore(Reducer, preloadedState, reduxMiddleware);
@ -29,17 +30,26 @@ if (preloadedState) {
store = createStore(Reducer, reduxMiddleware);
}
// run the saga middlweare
sagaMiddleware.run(rootSaga);
function Client () {
this.configureSiteDetails = (userConfig) => {
siteConfig.update(userConfig);
};
this.start = () => {
// run the saga middlweare
sagaMiddleware.run(rootSaga);
// render the app
hydrate(
<Provider store={store}>
<BrowserRouter>
<GAListener>
<App />
</GAListener>
</BrowserRouter>
</Provider>,
document.getElementById('react-app')
);
// render the app
hydrate(
<Provider store={store}>
<BrowserRouter>
<GAListener>
<App />
</GAListener>
</BrowserRouter>
</Provider>,
document.getElementById('react-app')
);
};
};
module.exports = Client;

View file

@ -2,7 +2,6 @@ const { customComponents } = require('siteConfig.js');
function getDeepestChildValue (parent, childrenKeys) {
if (!parent[childrenKeys[0]]) {
console.log('NO PAGE FOUND FOR:', childrenKeys[0], 'in', parent);
return null;
}
let childKey = childrenKeys.shift(); // .shift() retrieves the first element of array and removes it from array
@ -24,6 +23,7 @@ export const dynamicImport = (filePath) => {
throw new Error('file path provided to dynamicImport() must be a string');
}
if (!customComponents) {
console.log('No customComponents found in siteConfig.js');
return null;
}
// split out the file folders // filter out any empty or white-space-only strings
@ -32,8 +32,10 @@ export const dynamicImport = (filePath) => {
// i.e. customComponents[folders[0]][folders[2][...][folders[n]]
const component = getDeepestChildValue(customComponents, folders);
if (component) {
return component; // return custom component
console.log('Found custom component:', component);
return component;
} else {
console.log('Found custom component:', component);
return null;
}
};

File diff suppressed because one or more lines are too long

11928
exports/nodeBundle.js Normal file

File diff suppressed because one or more lines are too long

11931
index.js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -6,9 +6,9 @@ module.exports = {
target: 'web',
entry : ['babel-polyfill', 'whatwg-fetch', './client/index.js'],
output: {
path : Path.join(__dirname, 'public/bundle/'),
publicPath: 'public/bundle/',
filename : 'bundle.js',
path : Path.join(__dirname, 'exports/'),
publicPath: 'exports/',
filename : 'clientBundle.js',
},
module: {
loaders: [

View file

@ -1,7 +1,7 @@
const packageBaseConfig = require('./webpack.package.common.js');
const clientBaseConfig = require('./webpack.client.common.js');
// const clientBaseConfig = require('./webpack.client.common.js');
module.exports = [
clientBaseConfig,
// clientBaseConfig,
packageBaseConfig,
];

View file

@ -10,11 +10,11 @@ module.exports = {
__dirname: false,
},
externals: [nodeExternals()],
entry : ['babel-polyfill', 'whatwg-fetch', './speech.js'],
entry : ['babel-polyfill', 'whatwg-fetch', './speechPackage.js'],
output : {
path : Path.join(__dirname, '/'),
publicPath : '/',
filename : 'index.js',
path : Path.join(__dirname, 'exports/'),
publicPath : 'exports/',
filename : 'nodeBundle.js',
library : '',
libraryTarget: 'commonjs-module',
},