GithubHelp home page GithubHelp logo

ptzagk / svelte-typescript-webpack-starter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from brakmic/svelte-typescript-webpack-starter

0.0 0.0 0.0 829 KB

Svelte-Framework Starter with TypeScript, WebPack, Bootstrap, Font-Awesome, and some other goodies

License: MIT License

JavaScript 82.82% TypeScript 13.01% CSS 3.36% HTML 0.81%

svelte-typescript-webpack-starter's Introduction

Svelte-TypeScript-WebPack-Starter

This is a Svelte Starter-Project containing:

  • Svelte v2.9.9
  • TypeScript
  • jQuery 3
  • WebPack 4
  • Bootstrap 3
  • Font-Awesome
  • RxJS
  • Lodash
  • whatwg-fetch

Demo app

svelte_demo

This demo uses jquery.dataTables and Toastr plugins. Toastr is currently inactive but its package still available.

Structure

The core of the app is located in the init directory.

File Function
main.ts boots the initial code
polyfills.ts imports browser polyfills
vendor.ts imports all 3rd party scripts

main.ts contains these two lines of code that instantiate the app.

import { Main } from 'app/components';
Main('#svelte-app');

We import the Main function that takes a CSS selector to hook up the Svelte component. The definition of the component itself is located main.sve.

After a successful start the app will also provide a reference to itself in a globally available object window.app.

Of course, this is for testing purposes only.

There's no rule that Svelte components have to be named with a *.sve extension. It's just my own way of distinguishing between 'ordinary' HTMLs and those containing Svelte code. If you don't like this approach, simply change the regex for svelte-loader in webpack.common.js.

The Svelte component from this demo is located here and comprises of three parts:

I've tried to produce a demo that does something more complex than Hello World!

  • It fetches JSON-data from a remote server
  • Presents those data in a nicely looking table
  • It even displays a toast! :-)

The fetch-functionality is located in a separate API that'll be of some use to you in more complex scenarios, I hope.

The handling of tabular data is located in a few custom methods that follow Svelte's rules.

All the Styles are located here.

WebPack Configuration

Many parts of the webpack configuration are based on the configs from Angular2-WebPack-Starter.

The main Webpack.config.js in the root directory contains a simple switch statement that selects the appropriate version depending on your current settings (prod or dev).

Installation

npm install

Then type

npm run start:server

to run the app on http://localhost:3000.

To create a development build type

npm run build:dev

Afterwards, either copy the newly created dist folder to your web server or type

npm run server:prod

to launch a local server on http://localhost:8080

For productive builds use build:prod.

License

MIT

svelte-typescript-webpack-starter's People

Contributors

brakmic 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.