'How to set up rollup so that a Svelte project is automatically compiled on save without being served?

In a Svelte project there are already three scripts set up inside the package.json file

"scripts": {
    "build": "rollup -c",
    "dev": "rollup -c -w",
    "start": "sirv public --single"
  },

What I understand from the rollup.config.js file

  • running npm run build compiles the project to the public folder and minifies the files once
  • running npm run dev compiles without minifying and automatically runs npm run start after compilation so the public folder is served and reloaded on change

Since I'm using firebase emulators which includes emulating the hosting and serving of the public directory I'm looking for a way to only automatically compile the Svelte project when saving without the serving ~ how can I achieve this?

EDIT: How can I achieve this by modifying the rollup.config in a way that an additional script e.g. "autobuild": "..." can be added to easily switch between the different modes?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source