Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process.env, global var, warning "plugin svelte: 'X' is not defined", plugin-replace #4662

Closed
frederikhors opened this issue Apr 11, 2020 · 2 comments

Comments

@frederikhors
Copy link

I'm using this in rollup.config.js:

import replace from 'rollup-plugin-replace';
...
const isProd = process.env.NODE_ENV === 'production';
...
replace({
  IS_PRODUCTION: isProd,
}),

and in my Svelte code like this ():

{#if !IS_PRODUCTION && failure}
  <p>{failure}</p>
{/if}

It works!

But I get an annoying warning in console during compilation:

(!) Plugin svelte: 'IS_PRODUCTION' is not defined
src\Router.svelte
101: {/if}
102:
103: {#if !IS_PRODUCTION && failure}

How to fix it?

@Conduitry
Copy link
Member

Use the onwarn option to rollup-plugin-svelte to selectively suppress warnings. https://github.com/sveltejs/rollup-plugin-svelte#usage

@frederikhors
Copy link
Author

There is no way to use comments instead?

Like eslint: /* global IS_PRODUCTION */?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants