Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(framework): make assets path configurable #2214

Merged
merged 9 commits into from
Sep 16, 2020
Merged

Conversation

vladitasev
Copy link
Contributor

@vladitasev vladitasev commented Sep 14, 2020

This has been a highly requested feature for a long time. Although resource path is a build-time artefact, it often makes sense to build once and deploy in multiple, previously unknown directories.

Changes:

  • New configuration setting: assetsPath
  • Users have the capability to build with DEPLOY_PUBLIC_PATH or to use assetsPath at runtime (or both).

Option1: build-time

DEPLOY_PUBLIC_PATH=/my/resources/ yarn build

(for Windows: DEPLOY_PUBLIC_PATH="\/my\/resources\/" yarn build)

Option2: runtime

	<script data-ui5-config type="application/json">
		{
			"assetsPath": "/my/resources/"
		}
	</script>

BREAKING CHANGE: Running the production build command: yarn build will now generate the .json resources asset paths without /resources/ in the beginning. The yarn start command remains unchanged - it will implicitly set DEPLOY_PUBLIC_PATH to /resources/ as before.

Before the change, the build generates for example:

var SAPIcons = "/resources/SAP-icons.33a03c68298d0449.json";
registerIconBundle("SAP-icons", SAPIcons);

After the change, without setting DEPLOY_PUBLIC_PATH it will generate:

var SAPIcons = "SAP-icons.33a03c68298d0449.json";
registerIconBundle("SAP-icons", SAPIcons);

In order to have the old yarn build behavior run:

DEPLOY_PUBLIC_PATH=/resources/ yarn build

(for Windows: DEPLOY_PUBLIC_PATH="\/resources\/" yarn build)

closes: #2167
closes: #2169
related to: #2205

ilhan007
ilhan007 previously approved these changes Sep 15, 2020
@ilhan007
Copy link
Member

I think this would also resolves the 2nd part of this issue #2169
"2. It does not have a clean solution to identify a dynamic subdirectory where all the translations for a library should come from"

Copy link
Contributor

@pskelin pskelin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two minor documentation fixes, otherwise looks good

README.md Outdated
@@ -168,6 +168,8 @@ yarn build # to build the project
Afterwards, you can find the build output in the `dist` folder of the corresponding package folder.
For example, to find the Button component (that belongs to the `main` package), look inside the `packages/main/dist` folder.

*Note: before building the project you can also set the `PUBLIC_DEPLOY_PATH` environment variable to specify the path where non-bundled assets will be fetched from*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is DEPLOY_PUBLIC_PATH

@@ -168,6 +168,8 @@ yarn build # to build the project
Afterwards, you can find the build output in the `dist` folder of the corresponding package folder.
For example, to find the Button component (that belongs to the `main` package), look inside the `packages/main/dist` folder.

*Note: before building the project you can also set the `PUBLIC_DEPLOY_PATH` environment variable to specify the path where non-bundled assets will be fetched from*

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be good to add the example from the commit description in the docs
DEPLOY_PUBLIC_PATH="\/my\/resources\/" yarn build

note however that this gives the wrong result on mac (when reading from nodejs)
DEPLOY_PUBLIC_PATH: '\\/my\\/resources\\/'

@vladitasev vladitasev merged commit 16c46da into master Sep 16, 2020
@vladitasev vladitasev deleted the assets-path branch September 16, 2020 08:54
Todor-ads pushed a commit to Todor-ads/ui5-webcomponents that referenced this pull request Sep 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants