roxiness / routify-starter

https://example.routify.dev/
198 stars 55 forks source link

Rollup Build Environment #61

Closed lamualfa closed 3 years ago

lamualfa commented 4 years ago

Why Routify Starter Template use process.env.ROLLUP_WATCH in rollup.config.js to detect production mode instead use process.env.BUILD as written in official Rollup documentation? See Rollup Environment section.

I think the use of process.env.BUILD is more semantic and better than use process.env.ROLLUP_WATCH because I assume that there are additional Rollup plugins or user detect production mode via process.env.BUILD. BUILD is more standardized and widely used.

I can make a pull request to change some configuration if needed.

Sorry for the mistakes. Thanks.

jakobrosenberg commented 4 years ago

When possible, we try to align with the official Svelte template. Even if we have diverged far by now.

https://github.com/sveltejs/template/blob/master/rollup.config.js#L7

I assume the use of watch is for simplicity and SSOT. rollup -c build & production rollup watch & development

The alternative would be rollup -c --environment BUILD:production build & production rollup -c --environment BUILD:development build & development rollup --environment BUILD:production watch & production rollup --environment BUILDdevelopment watch & development

I can't speak for others, but for me watch has become synonymous with development and single-build with production.

One solution to this could be

process.env.BUILD = process.env.ROLLUP_WATCH ? 'development' : 'production'

That would keep ROLLUP_WATCH as the SSOT, while providing process.env.BUILD for standardized libraries.

I'd be happy to hear some counter points to this.