Hello! Is there any updated documentation about ho...
# compose-web
g
Hello! Is there any updated documentation about how to publish - for instance to githubpages -, the result of
./gradlew wasmJsBrowserProductionWebpack
? I’ve found a youtube video from @Abdul Basit but I guess is a bit outdated regarding which folders/files to copy from. I’ve a sample running but I’ve found out in the recent compose multiplatform releases things have changed a bit.
t
try
wasmJsBrowserDistribution
, and the build should be in
./composeApp/build/dist/wasmJs/productionExecutable
1
g
Thanks! Actually that task merges exactly all the files needed. Using
…WebPack
I had to do it by hand
❤️ 1
b
Check out the docs
c
I do it like this: // build.gradle.kts (:composeApp)
Copy code
// Publish to GitHub Pages
// Task to copy from ./composeApp/build/dist/wasmJs/productionExecutable to ./docs
tasks.register("copyWasmJsToDocs") {
	group = "build"
	doLast {
		val wasmJsDir = project.file("./build/dist/wasmJs/productionExecutable")
		val docsDir = file(rootDir.path + "/docs")
		wasmJsDir.copyRecursively(docsDir, overwrite = true)
	}
}
tasks.getByName("wasmJsBrowserDistribution").finalizedBy("copyWasmJsToDocs")


// Task to clean ./docs (docs is the dir that will be published to GitHub Pages)
tasks.register("cleanDocs") {
	group = "build"
	doLast {
		val docsDir = file(rootDir.path + "/docs")
		docsDir.deleteRecursively()
	}
}
tasks.getByName("clean").dependsOn("cleanDocs")
Run the
./gradlew copyWasmJsToDocs
task, and then push your changes to github. This assumes you have github pages setup to publish: https://kotlinlang.org/docs/wasm-get-started.html#publish-on-github-pages
❤️ 1
a
I also have CI/CD setup, which follows same approach . One PR is merged, it will build and make distributilable, and the copy paste those to docs.
t
I made a github workflow to deploy on gh pages
Copy code
name: Compile and push the compiled files only to the compiled branch

on:
  push:
    branches:
      - main

jobs:
  build:
    name: Compile and Push
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
    - uses: actions/checkout@v4
    - name: Set up JDK 21
      uses: actions/setup-java@v4
      with:
        java-version: '21'
        distribution: 'temurin'

    # See: <https://github.com/gradle/actions/blob/main/setup-gradle/README.md>
    - name: Setup Gradle
      uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
      with:
        gradle-version: 8.6

    - name: Build the production site
      run: ./gradlew wasmJsBrowserDistribution
    
    - name: Deploy
      uses: peaceiris/actions-gh-pages@v3
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        user_name: ${{ vars.USER_NAME }}
        user_email: <${{ vars.USER_EMAIL }}>
        publish_dir: ./composeApp/build/dist/wasmJs/productionExecutable
❤️ 2
👍 1