diff --git a/package.json b/package.json
index 628b8c1a139..586712803fa 100644
--- a/package.json
+++ b/package.json
@@ -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",
diff --git a/src/core/client/base.js b/src/core/client/base.js
index ad125b373c0..a510d4a9cd7 100644
--- a/src/core/client/base.js
+++ b/src/core/client/base.js
@@ -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) => {
+ 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 ;
- }
-
- render(
-
-
-
-
- ,
- document.getElementById('react-view')
- );
+ const store = createStore(initialState);
+
+ function reduxAsyncConnectRender(props) {
+ return ;
+ }
+
+ render(
+
+
+
+
+ ,
+ document.getElementById('react-view')
+ );
+ });
}
diff --git a/src/core/containers/ServerHtml.js b/src/core/containers/ServerHtml.js
index 3f5b3b3acf5..e91c08e7a8c 100644
--- a/src/core/containers/ServerHtml.js
+++ b/src/core/containers/ServerHtml.js
@@ -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],
diff --git a/webpack.prod.config.babel.js b/webpack.prod.config.babel.js
index e3d8e0c5df1..f7bf782fd7a 100644
--- a/webpack.prod.config.babel.js
+++ b/webpack.prod.config.babel.js
@@ -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',
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(),