

If you are familiar with Vue.js, it’s a similar concept. This file is the entry point and in this case initializes the App component, which is defined in App.svelte, a single file component: export let name h1 ! The src folder contains all you need to tweak the app: the main.js file: We’ll use the -y flag to use default settings.

Next, let’s navigate into that directory and initialize a new npm project. First, we’ll create our application directory, which we’ll call my-svelte-app: mkdir my-svelte-app. You’re now ready to open the code in your favorite editor. Let’s create a super simple Svelte app to start with. If you point your browser there, you’ll see the “Hello world!” example: This will start the app on localhost, on port 5000, by default: We’re now ready to run our Svelte site in development mode, by running npm run dev Plus npm-run-all, a CLI tool that is used to run multiple npm scripts in parallel, or sequential. At the time of writing, those are the dependencies of that project template: "npm-run-all" "rollup" "rollup-plugin-commonjs" "rollup-plugin-livereload" "rollup-plugin-node-resolve" "rollup-plugin-svelte" "rollup-plugin-terser" "svelte"Īs you can see, it’s the Svelte core, plus Rollup (a Webpack alternative) and some of its plugins.

#LIVERELOAD ROLLUP INSTALL#
Now go into that firstapp folder and run npm install to download the additional dependencies of the template. Looking at the code, the problem is, that if you do not specify an option to livereload () it won't use your configs dest but the current working dir. This will download and run the degit command, which in turn downloads the latest code of the Svelte project template living at, into the firstapp folder. reload once and use current bundle), if you specify just the dist folder, or more precisely the folder that will contain your generated bundle. In particular we’re going to run this: npx degit sveltejs/template firstapp Rollup is a module bundler which will transform, tree-shake and regroup our ES modules into optimized chunks to be fed to (in our case) browsers. Node installs the npx command, which is a handy way to run Node commands.
#LIVERELOAD ROLLUP HOW TO#
Check out my how to install Node.js post if you don’t have it already!Īnd make sure it’s the latest version ( how to update Node.js). Compared to React, Vue, Angular and other frameworks, an app built using Svelte is compiled beforehand, your site visitors don’t have to be served the framework and libraries code, and as a result all the fruition of the experience is smoother, consumes less bandwidth, and everything feels faster and lightweight.Īs with Hugo, which disappears at deployment and generates plain HTML, Svelte disappears and all you get is plain JavaScript.īut let’s jump to the meat of the article. Svelte is a JavaScript framework that gives me the same feeling.
#LIVERELOAD ROLLUP GENERATOR#
Since I started using Hugo as a static site generator to create websites, I’ve grown to love this approach to publishing on the web, compared to using a CMS that generated pages dynamically, as I was used to - in the past.
