GithubHelp home page GithubHelp logo

kurdin / svelte-router-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from andorbal/svelte-router-example

0.0 2.0 0.0 48 KB

Simple Svelte app that uses a router to select "pages."

License: MIT License

JavaScript 64.37% HTML 35.63%

svelte-router-example's Introduction

svelte-router-example

Simple Svelte app that uses a router to select "pages."

Purpose

TL;DR Experimental app to test how a router could be implemented using Svelte.

This is a very simple "app" that I'm going to use to test how I'd like a router implemented using Svelte. I'm currently leveraging as much existing code as I can, like history and route-parser. This way I can focus on only the Svelte aspects.

How to use

Just clone this repo, remove (or replace) git's origin remote, and build through npm.

$ git clone https://github.com/Andorbal/svelte-router-example.git
$ cd svelte-router-example
$ git remote rm origin
$ npm install
$ npm start

This will start a webserver on port 3000, and uses livereload. So you can open your browser, point it at http://localhost:3000, and edit away!

Options

When running npm start or npm run build, you can set a few environment variables that affects how the app gets built.

NODE_ENV

$ NODE_ENV=production npm run build

Setting NODE_ENV to 'production' will cause the app to build in production mode. This means removing things like livereload and running the code through uglify to minify the output.

APP_BASE_PATH

$ APP_BASE_PATH=/foo npm run build

APP_BASE_PATH will let you specify a root directory where your app will live. By default, the app assumes that you'll be running at the root of your server so all routes and url references reflect that. If you plan on serving the app from some other path, you can specify that with this environment variable. The dev server will do its best to mimic this path, but if you're running through a different server, you'll need to make sure the contents of the build directory actually live in the path you specified.

Next steps

I want to eventually extract the router code into an npm module so that other apps could make use of it. I'd also like to add more configuration options so that it's on par with what react-router can do.

License

MIT

svelte-router-example's People

Contributors

andorbal avatar

Watchers

James Cloos avatar Sergey 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.