infor-cloud / m3-h5-sdk

https://infor-cloud.github.io/m3-h5-sdk/
34 stars 20 forks source link

Use minified enterprise(-ng) versions in angular-soho app. #149

Open swuendri opened 1 year ago

swuendri commented 1 year ago

This PR is a replacement of #114 to use minified version of themes and cultures in applications generated with odin new. See also the issue #118. Thank you to @dohjon for the example!

Currently there is no option to include theme-new* files only.

tmcconechy commented 1 year ago

I think that setting just loads the node_modules/ids-enterprise/dist/js/cultures ones with .min.js instead of js.

So maybe you could use it if it still works? Or do the same and load the locales in with .min.js depending what your doing?

But they are published as minfied if you look in node_modules/ids-enterprise/dist/js/cultures

swuendri commented 1 year ago

I believe my question wasn't precise enough. Let me try it again.

The Goal

We want to use the minified culture js files in a Angular project.

The documented way we can reach it

Setting the SohoConfig.minifyCultures to true before Soho.Locale will be initialized. We can reach this by putting the following code into index.html

<script>
      window["SohoConfig"] = { minifyCultures: true };
</script>

The way that we want to go

We want to set the usage of minified culture files in the same way we set the path to the cultures itself in our Angular module, before we set/load the current locale. Example:

            Soho.Locale.culturesPath = 'assets/ids-enterprise/js/cultures/';
            Soho.Locale.minifyCultures = true;

Why we can't/won't go this way

Currently there is no "public" property in Soho.Locale to force the loading of minified culture files. But there is a property called minify in class Locale of ids-enterprise, which is initialized by the value of SohoConfig.minifyCultures. And this property is also mentioned as parameter to initialize the Locale class.

image

On the other hand Locale.minify isn't named in ids-enterprise-ng typings SohoLocaleStatic (https://github.com/infor-design/enterprise-ng/blob/main/projects/ids-enterprise-typings/lib/locale/soho-locale.d.ts). So we cannot easily use the property.

The final question

Is it possible to introduce the property minify in ids-enterprise-ng typings @tmcconechy? Or is the property more of a private one?

swuendri commented 1 year ago

@anhallbe, do not merge the PR now. The build of Angular Soho App breaks as expected but the workflow is successful. I will take a look on it.

swuendri commented 1 year ago

@anhallbe, I have changed the cli/src/cli.ts file to return an error in case of unsuccessful build. Should I create a separate PR for this? Or is it okay to change it within this PR?

No the build breaks, which is my expected behavior for the moment. If there is a newer version of enterprise-ng available with our change, I trigger here again.

anhallbe commented 1 year ago

You can keep it in the PR

swuendri commented 1 year ago

@anhallbe, ids-enterprise-ng contains our necessary change starting with version 14.7.0. There is currently the first bug fix version available which I introduced here. In my opinion this PR is ready to merge.