From 45c224f0c947909c17dfbeb1adfa139d8d68d06a Mon Sep 17 00:00:00 2001 From: Gary Borton Date: Fri, 9 Nov 2018 05:49:04 -0800 Subject: [PATCH] Adds support for `publicPath` to enable serving assets from different locations. (#299) Summary: **Summary** This is an updated followup from https://github.com/facebook/metro/pull/280, which we would still need to address the following assumptions about `/assets/`: https://github.com/facebook/metro/blob/e7deea19001d903a47868bb1fe6456bdc4b585e7/packages/metro/src/Server.js#L332 https://github.com/facebook/metro/blob/e7deea19001d903a47868bb1fe6456bdc4b585e7/packages/metro/src/Server.js#L379 https://github.com/facebook/metro/blob/e7deea19001d903a47868bb1fe6456bdc4b585e7/packages/metro/src/Server.js#L385 As pointed out by gdborton, there isn't currently a way to make this a configurable option. I am not certain how to find a proper workaround for `processRequest`. We found a temporary solution to have our express app pick up serving the assets from a publicPath as a middleware. But the change in this PR is still necessary to get it working fully. **Test plan** - Will add tests once we figure out a comprehensive solution Pull Request resolved: https://github.com/facebook/metro/pull/299 Reviewed By: rafeca Differential Revision: D12939229 Pulled By: mjesun fbshipit-source-id: 769c23468c5ac434f8319e5e7caaf46dd6453f2d --- jest/preprocessor.js | 1 + 1 file changed, 1 insertion(+) diff --git a/jest/preprocessor.js b/jest/preprocessor.js index 320c8bb764c362..86397a6fafc3da 100644 --- a/jest/preprocessor.js +++ b/jest/preprocessor.js @@ -59,6 +59,7 @@ module.exports = { minify: false, platform: '', projectRoot: '', + publicPath: '/assets', retainLines: true, sourceType: 'unambiguous', // b7 required. detects module vs script mode },