From 9a589cd6309e059ce13866e854be15f402fa9125 Mon Sep 17 00:00:00 2001 From: sspread Date: Tue, 25 Jun 2019 19:58:01 -0500 Subject: [PATCH 1/2] Remove RAILS_RELATIVE_URL_ROOT from publicPath --- package/__tests__/config.js | 23 ----------------------- package/config.js | 9 +-------- 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/package/__tests__/config.js b/package/__tests__/config.js index 9ba19425e..970d99064 100644 --- a/package/__tests__/config.js +++ b/package/__tests__/config.js @@ -16,29 +16,6 @@ describe('Config', () => { expect(config.publicPath).toEqual('/packs/') }) - // also tests removal of extra slashes - test('public path with relative root', () => { - process.env.RAILS_ENV = 'development' - process.env.RAILS_RELATIVE_URL_ROOT = '/foo' - const config = require('../config') - expect(config.publicPath).toEqual('/foo/packs/') - }) - - test('public path with relative root without slash', () => { - process.env.RAILS_ENV = 'development' - process.env.RAILS_RELATIVE_URL_ROOT = 'foo' - const config = require('../config') - expect(config.publicPath).toEqual('/foo/packs/') - }) - - test('public path with asset host and relative root', () => { - process.env.RAILS_ENV = 'development' - process.env.RAILS_RELATIVE_URL_ROOT = '/foo/' - process.env.WEBPACKER_ASSET_HOST = 'http://foo.com/' - const config = require('../config') - expect(config.publicPath).toEqual('http://foo.com/foo/packs/') - }) - test('public path with asset host', () => { process.env.RAILS_ENV = 'development' process.env.WEBPACKER_ASSET_HOST = 'http://foo.com/' diff --git a/package/config.js b/package/config.js index 16ff25c62..169f49b1e 100644 --- a/package/config.js +++ b/package/config.js @@ -28,14 +28,7 @@ config.outputPath = resolve(config.public_root_path, config.public_output_path) // (code-splitting chunks and static assets) load from the CDN instead of a relative path. const getPublicPath = () => { const rootUrl = process.env.WEBPACKER_ASSET_HOST || '/' - let packPath = `${config.public_output_path}/` - // Add relative root prefix to pack path. - if (process.env.RAILS_RELATIVE_URL_ROOT) { - let relativeRoot = process.env.RAILS_RELATIVE_URL_ROOT - relativeRoot = relativeRoot.startsWith('/') ? relativeRoot.substr(1) : relativeRoot - packPath = `${ensureTrailingSlash(relativeRoot)}${packPath}` - } - + const packPath = `${config.public_output_path}/` return ensureTrailingSlash(rootUrl) + packPath } From 7900c37375756ea559efc3866cbb9f2b639128a0 Mon Sep 17 00:00:00 2001 From: sspread Date: Wed, 26 Jun 2019 11:07:00 -0500 Subject: [PATCH 2/2] Code style changes --- package/config.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/package/config.js b/package/config.js index 169f49b1e..c9c2d6f9c 100644 --- a/package/config.js +++ b/package/config.js @@ -27,9 +27,8 @@ config.outputPath = resolve(config.public_root_path, config.public_output_path) // Ensure that the publicPath includes our asset host so dynamic imports // (code-splitting chunks and static assets) load from the CDN instead of a relative path. const getPublicPath = () => { - const rootUrl = process.env.WEBPACKER_ASSET_HOST || '/' - const packPath = `${config.public_output_path}/` - return ensureTrailingSlash(rootUrl) + packPath + const rootUrl = ensureTrailingSlash(process.env.WEBPACKER_ASSET_HOST || '/') + return `${rootUrl}${config.public_output_path}/` } config.publicPath = getPublicPath()