Skip to content

Commit cbde93c

Browse files
committed
Add CDN deployment capabilities to Reactium main bundle and serve assets from the resource base url automatically when WEBPACK_RESOURCE_BASE environment variable is provided with full CDN base path to js bundle assets. Alternatively, you can add window.resourceBaseUrl to your html specifying this base URL.
1 parent d7dfc7f commit cbde93c

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

.core/server/renderer/index.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ ReactiumBoot.Hook.registerSync(
102102
ReactiumBoot.Hook.runSync('webpack-server-assets', webpackAssets);
103103
webpackAssets.forEach(asset =>
104104
AppScripts.register(asset, {
105-
path: `/assets/js/${asset}`,
105+
path: `${global.resourceBaseUrl}${asset}`,
106106
order: ReactiumBoot.Enums.priority.highest,
107107
footer: true,
108108
}),
@@ -218,6 +218,14 @@ ReactiumBoot.Hook.registerSync('Server.AppGlobals', (req, AppGlobals) => {
218218
serverValue: global.restAPI,
219219
});
220220
}
221+
222+
AppGlobals.register('resourceBaseUrl', {
223+
name: 'resourceBaseUrl',
224+
value:
225+
process.env.NODE_ENV === 'development'
226+
? '/'
227+
: process.env.WEBPACK_RESOURCE_BASE || '/assets/js/',
228+
});
221229
});
222230

223231
export const renderAppBindings = req => {

src/app/main.js

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import { Shell } from 'reactium-core/app/shell';
66

7+
__webpack_public_path__ = window.resourceBaseUrl || '/assets/js/';
8+
79
(async () => {
810
try {
911
await Shell();

0 commit comments

Comments
 (0)