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..c9c2d6f9c 100644 --- a/package/config.js +++ b/package/config.js @@ -27,16 +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 || '/' - 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}` - } - - return ensureTrailingSlash(rootUrl) + packPath + const rootUrl = ensureTrailingSlash(process.env.WEBPACKER_ASSET_HOST || '/') + return `${rootUrl}${config.public_output_path}/` } config.publicPath = getPublicPath()