Open gossi opened 2 years ago
I think keepAssets
doesn't have any support right now for composing with a preprocessor like postcss.
If your plan is to ship a single prebuilt CSS file, it's probably easier to not use keepAssets
and only use postcss
and just make sure it emits its file into the place where you want it to be (probably /dist
).
keepAssets
was made for the case where your Javascript has imports that refer to some assets files and you want rollup to leave those imports alone so that decisions about incorporating them can be left up to the consuming application. This is ideal when there are some assets that are always tied to a particular component, because that component can import them and then they're only ever loaded if the component is used.
A combined CSS file is also fine, if you're going to manually tell users that they're supposed to import it. This gives them an easier way to extend and override the styles, at the cost of moving more manual decisions to the users.
I realized a weird behavior, where
addon.keepAssets()
.... which is "eating" my newly created assets :cookie: The relevant part of my rollup config:1)
postcss
(fromrollup-plugin-postcss
) - it is configured to compile all*.css
files into onestyles.css
file at the root (through css modules and it works) 2) withaddon.keepAssets()
I want to keep the source css files (to export them, so others can compose from them)Now what is happening:
postcss()
is available and//addon.keepAssets()
: I have astyles.css
file ✅//postcss()
andaddon.keepAssets()
: Source css files are copied over ✅postcss()
andaddon.keepAssets()
: only source files, nostyles.css
❌ it feels like, it is eating mystyles.css
away, when I "turn this on"I tried to glob the styles file away with
addon.keepAssets('['**/!(styles).css']')
- but no change.Given the order in which rollup plugins are executed and their side-effects on each other is unclear to me, I don't understand this 🤷
Does
addon.keepAssets()
interfere with the other plugins? Is that a potential reason for my observed behavior? Where else I might have to look?