This is a template to build a multipage web app (MPA) with Svelte and Materialize CSS.
- Svelte framework
- Materialice CSS with custom colour palette
- Customizable html template
- Webpack 5
- Webpack dev server with hot reload
- A sample page with Materialize sidenav.
First clone this repo (replace myapp with the name of your app):
git clone https://github.com/aletome/svelte-materialize-template.git myapp
cd myappIf you don't want to keep all history of this project, delete .git hidden folder and init your new repo:
git initFinally install all dependencies:
npm installThat's all! You are ready to go!
To start webpack in dev mode with hot reload:
npm run devVisit localhost:8585 to see your app in the browser.
To generate production bundle:
npm run buildThis command create in public folder index.html, bundle.css and bundel-xxxxx.js, where xxxxx is a hash that changes every build.
If you need to change Materialize CSS default color palette use materialize-custom.scss.
In the exampe below I changed primary, secondary, success, error and link colors.
// 1. Custom Colors
// ==========================================================================
@import '../node_modules/materialize-css/sass/components/color-variables';
//Place here color scheme you want
$primary-color: color("teal", "lighten-2") !default;
$primary-color-light: lighten($primary-color, 15%) !default;
$primary-color-dark: darken($primary-color, 15%) !default;
$secondary-color: color("pink", "lighten-1") !default;
$success-color: color("green", "base") !default;
$error-color: color("red", "base") !default;
$link-color: color("light-blue", "darken-1") !default;
@import '../node_modules/materialize-css/sass/materialize.scss';To create a new:
- Create a folder inside
src/Pagesfolder. The name of the folder will be the name of html page. - Inside the new page folder create two files:
main.js(the namemain.jsis mandatory): this is the entry point of the new page;newpage.svelte(wherenewpageis a name you prefer): this is the svelte component file.
- In the
main.jsfile import thenewpage.sveltefile (import App from './newpage.svelte';).