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 to use index.html with build app #42

Open
lpil opened this issue May 22, 2024 · 1 comment
Open

How to use index.html with build app #42

lpil opened this issue May 22, 2024 · 1 comment

Comments

@lpil
Copy link

lpil commented May 22, 2024

Hello!

I'm trying to deploy my application but I'm having a problem where I don't know how to get the index.html file for the compiled application.

The build command doesn't move it to the priv static directory, and if you use the --minify flag Lustre writes the output files to a different location than normal so you can't copy it directly across.

What's the right way to do this?

Thanks,
Louis

@stewartrule
Copy link

Was wondering the same thing. As a workaround I've added the build artifacts to my .gitignore and added a small shell script (build_gh.sh) that builds the app, copies the index.html to the /priv/static/ folder, and then updates the paths.

gleam run -m lustre/dev build app --minify

cp ./index.html ./priv/static/index.html

sed -i 's/app\.css/app\.min\.css/' ./priv/static/index.html
sed -i 's/app\.mjs/app\.min\.mjs/' ./priv/static/index.html
sed -i 's/\/priv\/static/\./' ./priv/static/index.html

And added that as an extra build step before deploying to gh-pages:

jobs:
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - uses: erlef/setup-beam@v1
        with:
          otp-version: '26.0.2'
          gleam-version: '1.2.1'
          rebar3-version: '3'
      - run: gleam deps download
      - name: Setup Pages
        uses: actions/configure-pages@v5
      - name: Build
        run: ./build_gh.sh
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: './priv/static/'
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants