Skip to content
Advertisement

How to Compile a Svelte file to JavaScript from the Command line?

I’m new to Svelte. Quick question:

Is there a CLI for the Svelte compiler, and how do I access it?

I understand Svelte has a preconfigured setup that uses rollup and what not for building an app. That’s all good, but I only need the CLI for transforming a svelte file to pure js file. Something like:

svelte compile input.svelte --out=out.js

Update It seems like there is no CLI for the Svelte compiler. However, a brief outline of the compilation process is available here. In particular,the following code snippet, which can be used to build CLI.

JavaScript

Advertisement

Answer

For Svelte 3 there is no official CLI.

You’ll either write one:

JavaScript

and customize that one to your exact needs.

But most cases an existing build tool is a better option
and for most build tools there is plugin or loader available for Svelte.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement