All Projects → cerivitos → svelte-pwa-now

cerivitos / svelte-pwa-now

Licence: MIT license
A PWA ready Svelte v3.0 starter template with Tailwind, Now integration and optional Typescript suppot

Programming Languages

javascript
184084 projects - #8 most used programming language
Svelte
593 projects
CSS
56736 projects

Projects that are alternatives of or similar to svelte-pwa-now

instrument-cra
Little module for CRA applications to instrument code without ejecting react-scripts
Stars: ✭ 61 (-55.8%)
Mutual labels:  cypress, cypress-io
todo-graphql-example
Example Todo app on top of json-graphql-server
Stars: ✭ 20 (-85.51%)
Mutual labels:  cypress, cypress-io
cypress-watch-and-reload
Reloads Cypress when one of the watched files changes
Stars: ✭ 46 (-66.67%)
Mutual labels:  cypress, cypress-io
cypress-browserify-preprocessor
Cypress preprocessor for bundling JavaScript via browserify
Stars: ✭ 23 (-83.33%)
Mutual labels:  cypress, cypress-io
svelte-template-hot
Copy of official Svelte template with added HMR support
Stars: ✭ 61 (-55.8%)
Mutual labels:  rollup, svelte-v3
cypress-test-tiny
Tiny Cypress E2E test case
Stars: ✭ 48 (-65.22%)
Mutual labels:  cypress, cypress-io
cypress-angularjs-unit-test
Unit test Angularjs code using Cypress.io test runner
Stars: ✭ 23 (-83.33%)
Mutual labels:  cypress, cypress-io
cypress-retry
Retry just the failed Cypress.io tests using Cypress module API and AST rewriting
Stars: ✭ 16 (-88.41%)
Mutual labels:  cypress, cypress-io
cypress-angular-unit-test
Trying to load and bootstrap Angular component dynamically inside Cypress
Stars: ✭ 146 (+5.8%)
Mutual labels:  cypress, cypress-io
cypress-mochawesome-reporter
Zero config Mochawesome reporter for Cypress with screenshots
Stars: ✭ 48 (-65.22%)
Mutual labels:  cypress, cypress-io
cypress-upload-file-post-form
Solution for two Cypress testing use-cases I came across with: perform a direct http FORM request to the server containing a file and other parameters and upload a file into a form before submission
Stars: ✭ 59 (-57.25%)
Mutual labels:  cypress, cypress-io
tailwind-dashboard-template
Mosaic Lite is a free admin dashboard template built on top of Tailwind CSS and fully coded in React. Made by
Stars: ✭ 1,662 (+1104.35%)
Mutual labels:  tailwind, tailwind-css
TLE5012-Magnetic-Angle-Sensor
This repository includes an library for Arduino for the TLE5012 Magnetic Angle Sensor with SSC interface.
Stars: ✭ 37 (-73.19%)
Mutual labels:  cypress, cypress-io
cypress-get-it
Get elements by data attribute by creating a Cy command on the fly
Stars: ✭ 23 (-83.33%)
Mutual labels:  cypress, cypress-io
cypress-example-docker-circle-workflows
Cypress + Docker + CircleCI Workflows = ❤️
Stars: ✭ 29 (-78.99%)
Mutual labels:  cypress, cypress-io
cypress-example-circleci-orb
Demo of using the Cypress CircleCI Orb
Stars: ✭ 26 (-81.16%)
Mutual labels:  cypress, cypress-io
snapshot
Adds value / object / DOM element snapshot testing support to Cypress test runner
Stars: ✭ 114 (-17.39%)
Mutual labels:  cypress, cypress-io
angular-material-starter-template
🍄 Angular 14 boilerplate that comes with Material-UI, Tailwind3, Purgecss, Jest & Cypress Support, Optimal project structure & Interceptor inspired from popular blogs, source map analyzer tools, husky, all pre-configured and much more...
Stars: ✭ 104 (-24.64%)
Mutual labels:  cypress, tailwind
cypress-example-docker-compose
Example running Cypress tests against Apache server via docker-compose
Stars: ✭ 106 (-23.19%)
Mutual labels:  cypress, cypress-io
rollup-plugin-svelte-hot
Fork of official rollup-plugin-svelte with added HMR support (for both Nollup or Rollup)
Stars: ✭ 49 (-64.49%)
Mutual labels:  rollup, svelte-v3

icon Svelte PWA Now starter

A simple Svelte starter template with:

  • Tailwind CSS (from https://github.com/marcograhl/tailwindcss-svelte-starter)
  • Rollup copy assets plugin to serve static folders (eg. data or images)
  • Now integration
  • Cypress for testing
  • PWA ready, including basic service worker and social sharing meta data boilerplate
  • Typescript support (switch to the implement-ts branch)

Getting started

Make sure Node.js is installed. Clone the repo and

npm install

Start by

npm run dev

and go to localhost:5000.

Build for production using

npm run build

and serve the dist folder.

Details

Tailwind

Find out more about Tailwind CSS here. To extend Tailwind classes, go to tailwind.config.js and put in your customizations as an object under extend.

module.exports = {
  theme: {
    extend: {
      colors: {
        backgroundColor: "#f6f5f5",
        primaryColor: "#5bd1d7",
        secondaryColor: "#248ea9",
        accentColor: "#556fb5"
      }
    }
  },
  variants: {},
  plugins: []
};

For example, the template comes with custom colors which can then be used in html like <div class="backgroundColor"></div>.

Be sure to indicate postcss to your style tags like this

<style type="text/postcss"></style>

to see proper syntax highlighting and parsing in VS code.

More details can be found here.

Now integration

The template includes optional integration with the Now hosting service. The easiest way to get started is to link your Github repo to Now, which allows all pushes to be built and served automatically. The included now.json tells Now to automatically run the rollup build command (via package.json) and serve the dist folder.

If applicable, be sure to include your custom web domain under alias to tell Now to automatically alias your output to your domain.

{
  "version": 2,
  "alias": "https://ADD-DOMAIN-NAME-HERE",
  "builds": [
    {
      "src": "package.json",
      "use": "@now/static-build"
    }
  ],
  "routes": [
    {
      "src": "/(.*)",
      "headers": { "cache-control": "max-age=0,must-revalidate" },
      "dest": "dist/$1"
    }
  ]
}

There is also a .nowignore file which tells Now to ignore specified files, similar to .gitignore.

More info on Now integration with Github can be found here.

If you do not need Now integration, feel free to remove now.json and .nowignore.

Cypress testing

Cypress is included in the template. Simply use npm run test to start cypress integration testing. More info about writing cypress tests can be found at cypress.io.

Rollup copy assets plugin

By default, Rollup does not copy static folders to dist when building. If you have folders with static assets like data files or images, put the folder path in rollup.config.js like so.

...
import copy from "rollup-plugin-copy-assets";

const production = !process.env.ROLLUP_WATCH;
export default {
  ...
  plugins: [
    ...
    copy({
      assets: ["src/assets", "src/MORE-STATIC-FOLDERS"]
    }),
    ...
  ]
  ...
};

PWA boilerplate

Icons

The commonly required icons are at src/assets. Be sure to use the same filenames as they are referred to in the metadata at dist/index.html. Tip: Use Real Favicon Generator which automatically creates all the required icon sizes, and simply unzip the generated asset bundle into src/assets.

index.html metadata

The icons are all utilized in the <meta></meta> tags for Facebook, Twitter and Google indexing among others. Be sure to customize your app title and descriptions in all the tags.

Service worker

This template includes a basic service worker at dist/service-worker.js which simply checks against the currently held cache and loads from network if required. Feel free to further customize it for your needs.

Manifest

Customize dist/manifest.json with your PWA's info for installation. Note that the manifest requires a 512x512 icon which is not generated by Real Favicon Generator. You have to manually create that one on your own using something like https://onlinepngtools.com/resize-png.

Basic router

A very basic router is included as a renderless component at src/components/Router.svelte. It simply uses the browser History API to manage the browser history stack and updating the browser url. To use, you must manually do something like

window.history.pushState(
        {
          state1: newValue1,
          state2: newValue2
        },
        null,
        "?state1=" + newValue1 + "&state2=" + newValue2
      );

in the component where the state was updated, which will then change your browser window url to show the new state for your SPA.

The router also takes care of parsing incoming url parameters, which you must then manually pass to your state store (in this case src/store/store.js).

window.onload = function() {
    if (window.location.search.length > 0) {
      const params = window.location.search.substr(1);
      params.split("&").forEach(param => {
        const key = param.split("=")[0];
        const value = parseFloat(param.split("=")[1]);
        console.log(`Parameter of ${key} is ${value}`);
      });

      //UPDATE STATE WITH THESE PARAMS
      updateState();
    }
  };

This article probably explains it much better.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].