This is my boilerplate for different Admin UIs and simple projects implemented with Svelte.
It includes very basic things: infrastructure and very basic set of UI, literally only buttons and modals.
npm run build
for production buildnpm run dev
for development build (no minification)npm run watch
for development build + watch modenpm run start
for live server on http://localhost:3030/
docker*
(see below)To generate dist
folder without installing NPM packages and adding local garbage, use these commands:
docker build -f Dockerfile.prod -t svelte-min-pack .
in the project folder.docker run --name temp svelte-min-pack
dist
folder from container: docker cp temp:/app/dist ./dist
docker rm temp
docker image rm svelte-min-pack
OR
docker_build.cmd
script.In root folder run docker-compose up
to build the files. Result will be placed into dist
folder.
In root folder run docker-compose -f docker-compose.watch.yml up
to build the files. Result will be placed into dist
folder and Webpack will start watching.
node_modules
and dist
folders will be mapped.
In root folder run docker-compose -f docker-compose.start.yml up
to build the files. Result will be placed into dist
folder and application will start
watching. Webserver will be available on URL localhost:3030
.
node_modules
and dist
folders will be mapped.
npm i
npm run build
or npm run dev
npm run watch
to start watching.npm run start
to run dev webserver.To clean up unused things (pages, 3rd party components) you need to delete:
src/styles/syntax-example.less
- styles for example pages Note: remove @import "syntax-example";
line from src/styles/index.less
file.
src/pages/home/HomePage.svelte
- syntax highlight component
src/assets/prism
folder - syntax highlight engine (prism)
Unnecessary files: src/pages/*
folders.
Routing in the application uses two files: src/config/Routing.svelte
and src/pages/home/HomePage.svelte
.
First one is a physical routing: declaration of available routes:
<script lang="ts">
import {Route} from 'svelte-routing';
import HomePage from '../pages/home/HomePage.svelte';
import ModalPage from '../pages/modal/ModalPage.svelte';
import ButtonsPage from '../pages/buttons/ButtonsPage.svelte';
import RoutingPage from '../pages/routing/RoutingPage.svelte';
import RoutingParameterizedPage from '../pages/routing/RoutingParameterizedPage.svelte';
import RoutingSecondaryPage from '../pages/routing/RoutingSecondaryPage.svelte';
</script>
<div class="app-pages">
<Route path="buttons" component="{ButtonsPage}"/>
<Route path="routing" component="{RoutingPage}"/>
<Route path="routing/secondary" component="{RoutingSecondaryPage}"/>
<Route path="routing/:user/:record" let:params component="{RoutingParameterizedPage}"/>
<Route path="modal" component="{ModalPage}"/>
<Route path="home" component="{HomePage}"/>
<Route path="/">
<HomePage/>
</Route>
</div>
Second file is declaration of routes which are displayed in main menu:
export const menuRoutes = [
['home', 'Home'], // [route, title]
['routing', 'Routing'],
['modal', 'Modal'],
['buttons', 'Buttons'],
];
So you need only to create your pages and declare them here.
Good luck!