diff --git a/docs/3.x.x/en/advanced/customize-admin.md b/docs/3.x.x/en/advanced/customize-admin.md index 6a05474b98..ec2f4f31ec 100644 --- a/docs/3.x.x/en/advanced/customize-admin.md +++ b/docs/3.x.x/en/advanced/customize-admin.md @@ -165,14 +165,14 @@ It's very common to deploy the front-end and the back-end on different servers. "host": "/", // Note: The administration will be accessible from the root of the domain (ex: https//yourfrontend.com/) "backend": "http://yourbackend.com", "plugins": { - "source": "backend" // What does it means? The script tags in the index.html will use the backend value to load the plugins (ex: https://yourbackend.com/admin/content-manager/main.js). + "source": "backend" // What does it means? The script tags in the index.html will use the backend value to load the plugins (ex: https://yourbackend.com/dashboard/content-manager/main.js). } } } } ``` -The administration URL will be https://yourfrontend.com and every request from the panel will hit the backend at https://yourbackend.com. The plugins will be injected through the `origin` (means the API itself). In other words, the plugins URLs will be `https://yourbackend.com/admin/content-manager/main.js`. +The administration URL will be https://yourfrontend.com and every request from the panel will hit the backend at https://yourbackend.com. The plugins will be injected through the `origin` (means the API itself). In other words, the plugins URLs will be `https://yourbackend.com/dashboard/content-manager/main.js`. > Note: How it is possible? The API (the Strapi server) owns the plugin and these plugins are exposed through `https://yourbackend.com/admin/**/main.js` @@ -185,11 +185,11 @@ The DOM should look like this:
- - - - - + + + + + ``` diff --git a/packages/strapi-admin/admin/src/public-path.js b/packages/strapi-admin/admin/src/public-path.js index 9d68406e22..7efc38380a 100644 --- a/packages/strapi-admin/admin/src/public-path.js +++ b/packages/strapi-admin/admin/src/public-path.js @@ -1,5 +1,19 @@ // Retrieve URLs. -const remoteURL = window.location.port === '4000' ? 'http://localhost:4000/admin' : process.env.REMOTE_URL || 'http://localhost:1337/admin'; -const devURL = document.getElementsByTagName('body')[0].getAttribute('front'); +const remoteURL = (() => { + if (window.location.port === '4000') { + return 'http://localhost:4000/admin'; + } -__webpack_public_path__ = window.location.port === '4000' ? `${window.location.origin}/` : `${(devURL || remoteURL).replace(window.location.origin, '')}/`; + // Relative URL (ex: /dashboard) + if (process.env.REMOTE_URL[0] === '/') { + return (window.location.origin + process.env.REMOTE_URL).replace(/\/$/, ''); + } + + return process.env.REMOTE_URL.replace(/\/$/, ''); +})(); + +// Retrieve development URL to avoid to re-build. +const $body = document.getElementsByTagName('body')[0]; +const devFrontURL = $body.getAttribute('front') ? window.location.origin + $body.getAttribute('front').replace(/\/$/, '') : null; + +__webpack_public_path__ = window.location.port === '4000' ? `${window.location.origin}/` : `${(devFrontURL || remoteURL).replace(window.location.origin, '')}/`; diff --git a/packages/strapi-admin/scripts/setup.js b/packages/strapi-admin/scripts/setup.js index 3f95609aba..475d0c3372 100644 --- a/packages/strapi-admin/scripts/setup.js +++ b/packages/strapi-admin/scripts/setup.js @@ -40,7 +40,7 @@ if (isDevelopmentMode) { shell.echo('🏗 Building...'); const build = shell.exec(`cd ${path.resolve(appPath, 'admin')} && APP_PATH=${appPath} npm run build`, { - silent: true + silent: false }); if (build.stderr && build.code !== 0) { diff --git a/packages/strapi-helper-plugin/lib/internals/webpack/webpack.prod.babel.js b/packages/strapi-helper-plugin/lib/internals/webpack/webpack.prod.babel.js index 84ce5d9eba..410f2d2e0c 100755 --- a/packages/strapi-helper-plugin/lib/internals/webpack/webpack.prod.babel.js +++ b/packages/strapi-helper-plugin/lib/internals/webpack/webpack.prod.babel.js @@ -131,11 +131,11 @@ module.exports = base({ }, // Utilize long-term caching by adding content hashes (not compilation hashes) to compiled assets - output: { + output: _.omitBy({ filename: '[name].js', chunkFilename: '[name].[chunkhash].chunk.js', publicPath, - }, + }, _.isUndefined), // In production, we minify our CSS with cssnano postcssPlugins: [