Skip to content

How do we package this up? #29

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

Closed
Tracked by #42
Rockerby opened this issue Sep 23, 2023 · 2 comments
Closed
Tracked by #42

How do we package this up? #29

Rockerby opened this issue Sep 23, 2023 · 2 comments
Labels
bellissima Issues relating to the Umbraco Bellissima build

Comments

@Rockerby
Copy link
Contributor

Package format in Umbraco 14 is different to that of previous versions. The current setup is that the umbraco-package.json files (which defines the package) sits within samples\Umbraco14.Website\App_Plugins\Example.UI\umbraco-package.json - this should be within the actual package project and copy across during build.

@Rockerby Rockerby added the bellissima Issues relating to the Umbraco Bellissima build label Sep 23, 2023
@KevinJump
Copy link
Contributor

KevinJump commented Sep 23, 2023

You can still razor class library the package (and the json files) .

As long as the result of your build end up in a wwwroot folder, you can then use the StaticWebAssetBasePath value to point to the app_plugins folder.

when this is installed on an umbraco site the folder is seen

e.g

i have:

  • myPackage
    • wwwroot
    • my-package
      • public
        • umbraco-package.json
      • src
        • [the typescript for the package is here]
      • package.json
      • vite.config.js
      • etc

then in vite.config.ts

import { defineConfig } from "vite";

export default defineConfig({
  build: {
    lib: {
      entry: "src/my-element.ts", // your web component source file
      formats: ["es"],
    },
    outDir: "../wwwroot/my-package", // your web component will be saved in this location
    sourcemap: true,
    rollupOptions: {
      external: [/^@umbraco/],
    },
  },
});

running npm build puts the output in wwwroot/my-package/

Then in the mypackage.sln

<Project Sdk="Microsoft.NET.Sdk.Razor">

	<PropertyGroup>
		<TargetFramework>net8.0</TargetFramework>
		<Nullable>enable</Nullable>
		<ImplicitUsings>enable</ImplicitUsings>
		<StaticWebAssetBasePath>/App_Plugins</StaticWebAssetBasePath>

	</PropertyGroup>

</Project>

if this is packaged up as a nuget project, it will pack the wwwroot folder and when its installed on an Umbraco site, the /app_plugins/my-package folder will contain the umbraco-package.json and the scripts.

@ronaldbarendse
Copy link
Collaborator

PR #48 updates the project to a Razor Class Library that contains all the client assets, including the umbraco-package.json file. The GitHub Actions build also publishes an artifact with the NuGet package, so the packaging part is now all taken care of 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bellissima Issues relating to the Umbraco Bellissima build
Projects
None yet
Development

No branches or pull requests

3 participants