Importing css automatically in a Javascript module

128 views Asked by At

I have written a javascript module which has custom css which is required for the app to function correctly.

This module is built with webpack with css-loader, and the compiled css appears as dist/mymodule.css.

The module can then be used as follows:

import * as mymodule from 'mymodule'

However to get the styling we also need to explicitly import the compiled css.

import 'mymodule/dist/mymodule.css'

Is there a way to have the css imported automatically as part of importing the module, rather than having to explicitly add it?

0

There are 0 answers