I want to load RTL or LTR styles based on the user's locale.
I have tried to import('/path/to/RTL-style.css')
but it doesn't working - the styles are not getting applied.
They will be applied only if I mention this line in the top of the file, before any code execution, in this format:
import '/path/to/RTL-style.css'
and without parentesis ()
I am using Parcel bundler and babel polyfill included as the first dependency.
How to achieve what I try to do?
I found it, just do this when its css file:
import('/colors.css').then().catch(() => {})
And if its js file you can do this:
const module = await import('/path/to/jsfile')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.