Coder Social home page Coder Social logo

excel-split-web-tool's Introduction

sveltekit-gh-pages

Minimal SvelteKit set-up made deployable to GitHub Pages.

1) Use the static adapter

Install the SvelteKit static adapter to prerender the app.

package.json

  "devDependencies": {
+   "@sveltejs/adapter-static": "1.0.5",
    "@sveltejs/kit": "1.2.1",
    "gh-pages": "^5.0.0",
    "svelte": "^3.55.1",
    "vite": "^4.0.4"
  }

svelte.config.js

+ import adapter from "@sveltejs/adapter-static";

/** @type {import('@sveltejs/kit').Config} */
const config = {
  kit: {
+   adapter: adapter(),
  },
};

export default config;

Ensure your top-level +layout.js exports prerender = true.

// src/routes/+layout.js
export const prerender = true;

2) Modify paths.base in the config

  • kit.paths.base should be your repo URL subpath (see the Vite docs)
import adapter from "@sveltejs/adapter-static";

/** @type {import('@sveltejs/kit').Config} */
const config = {
  kit: {
    adapter: adapter(),
+   paths: {
+     base: process.env.NODE_ENV === "production" ? "/sveltekit-gh-pages" : "",
+   },
  },
};

export default config;

Note: You will also need to prepend relative paths with the SvelteKit base path so that your app can build successfully for production.

<script>
  import { base } from "$app/paths";
</script>

<a href="{base}/about">About</a>

3) Add a .nojekyll file to the build

The last step is to add a .nojekyll file to the build folder to bypass Jekyll on GitHub Pages.

package.json

{
  "scripts": {
    "dev": "vite dev",
    "build": "vite build",
    "deploy": "touch build/.nojekyll && gh-pages -d build -t true"
  }
}

Quick start

Use degit to quickly scaffold a new project:

npx degit metonym/sveltekit-gh-pages my-app
cd my-app && yarn install

Deploying to GitHub Pages

First, build the app by running yarn build.

Then, run yarn deploy to deploy the app to GitHub Pages.

excel-split-web-tool's People

Contributors

ubidy avatar nenjotsu avatar renenjovalente-ubidy avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.