feychu
feychu

Reputation: 1364

Flow type issue with inline webpack loader

I am using sass-variable-loader with webpack and because of limitation with extending webpack configuration, I just want to use it inline this way:

import variables from '!!sass-variable-loader!../../../src/styles/variables.scss'

This works as expected but when I try to run flow, it exits with this error:

import variables from '!!sass-variable-loader!../../../src/styles/variables.scss'
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ !!sass-variable-loader!../../../src/styles/variables.scss. Required module not found

Is there a way for Flow not to fail on this line?

Upvotes: 0

Views: 113

Answers (1)

kalley
kalley

Reputation: 18462

In your .flowconfig file, you can add the following (I have the initial !s optional, since they are, depending on your purpose):

[options]
module.name_mapper='^\(!!\)?sass-variable-loader!.+\.scss$' -> '<PROJECT_ROOT>/Stub.js.flow'

And Stub.js.flow looks like:

declare module Stub {
  declare var exports: { [key: string]: string };
}

You don't need to call the file that, but you'll need one that looks like that.

Upvotes: 1

Related Questions