Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
"babel-preset-react": "6.5.0",
"babel-preset-stage-2": "6.5.0",
"babel-register": "6.9.0",
"bundle-loader": "0.5.4",
"chai": "3.5.0",
"chalk": "1.1.3",
"cheerio": "0.20.0",
Expand Down
49 changes: 25 additions & 24 deletions src/core/client/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,30 @@ export default function makeClient(routes, createStore) {
const lang = getLanguage(html.getAttribute('lang'));
const locale = langToLocale(lang);
const appName = config.get('appName');
// eslint-disable-next-line global-require
const jedData = require(`json!../../locale/${locale}/${appName}.json`);
const i18n = new Jed(jedData);

if (initialStateContainer) {
try {
initialState = JSON.parse(initialStateContainer.textContent);
} catch (error) {
log.error('Could not load initial redux data');
// eslint-disable-next-line global-require, max-len
require(`bundle?name=[name]-i18n-[folder]!json!../../locale/${locale}/${appName}.json`)((jedData) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to move this into the config but I'm not sure how to do that in a good way at the moment.

const i18n = new Jed(jedData);

if (initialStateContainer) {
try {
initialState = JSON.parse(initialStateContainer.textContent);
} catch (error) {
log.error('Could not load initial redux data');
}
}
}
const store = createStore(initialState);

function reduxAsyncConnectRender(props) {
return <ReduxAsyncConnect {...props} />;
}

render(
<I18nProvider i18n={i18n}>
<Provider store={store} key="provider">
<Router render={reduxAsyncConnectRender} children={routes} history={browserHistory} />
</Provider>
</I18nProvider>,
document.getElementById('react-view')
);
const store = createStore(initialState);

function reduxAsyncConnectRender(props) {
return <ReduxAsyncConnect {...props} />;
}

render(
<I18nProvider i18n={i18n}>
<Provider store={store} key="provider">
<Router render={reduxAsyncConnectRender} children={routes} history={browserHistory} />
</Provider>
</I18nProvider>,
document.getElementById('react-view')
);
});
}
2 changes: 1 addition & 1 deletion src/core/containers/ServerHtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class ServerHtml extends Component {
const leafName = filePath.split('/').pop();
let sriProps = {};
// Only output files for the current app.
if (leafName.startsWith(appName)) {
if (leafName.startsWith(appName) && !leafName.includes('i18n')) {
if (includeSri) {
sriProps = {
integrity: sriData[leafName],
Expand Down
7 changes: 5 additions & 2 deletions webpack.prod.config.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,17 @@ export default {
new webpack.NormalModuleReplacementPlugin(/config$/, 'core/client/config.js'),
// Substitutes client only config.
new webpack.NormalModuleReplacementPlugin(/core\/logger$/, 'core/client/logger.js'),
// This allow us to exclude locales for other apps being built.
new webpack.ContextReplacementPlugin(
/locale$/,
new RegExp(`^\\.\\/.*?\\/${appName}\\.json$`)
),
new ExtractTextPlugin('[name]-[chunkhash].css', {allChunks: true}),
new SriStatsPlugin({
algorithm: 'sha512',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this any more since the config moved.

write: true,
saveAs: path.join(__dirname, 'dist/sri.json'),
}),
// ignore dev config
new webpack.IgnorePlugin(/\.\/webpack\.dev/, /\/babel$/),
// optimizations
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
Expand Down