This is a project template for Express and Svelte apps. It includes basic TypeScript setup and Jest tests setup for the backend.
To create a new project based on this template using degit:
npx degit somi92/express-svelte-template my-app
cd my-app
Note that you will need to have Node.js installed.
Change appropriate project fields in package.json
(name, version and description).
Install the dependencies:
cd my-app
npm install
Start development mode:
npm run dev:live
The script will run the backend and frontend build processes in parallel.
Backend Express API will be started on localhost:8080. Navigate to localhost:8080/hello to see a sample response. Make a change to TypeScript (.ts
) file in src
, save it and reload the page to see your changes.
Navigate to localhost:5000. You should see your frontend Svelte app running. Edit a component file in src/client
, save it and the page should automatically reload so you can see your changes.
By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the sirv
commands in package.json to include the option --host 0.0.0.0
.
Run production build:
npm run prod
The script will run the production build process which outputs its results in the dist
directory. You can run the production build locally with:
npm run prod:start
Navigate to localhost:8080 to see your app running (both the API and the frontend are served from localhost:8080).
To run the both scripts in one go:
npm run prod:live
Run the backend tests with:
npm run test
To run the tests in watch mode (tests will re-run on save):
npm run test:watch