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

How do we package this up? #29

Open
Tracked by #42
Rockerby opened this issue Sep 23, 2023 · 1 comment
Open
Tracked by #42

How do we package this up? #29

Rockerby opened this issue Sep 23, 2023 · 1 comment
Labels
Umbraco 14 Issues relating to the Umbraco 14 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 Umbraco 14 Issues relating to the Umbraco 14 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.

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

No branches or pull requests

2 participants