Closed nternetinspired closed 5 years ago
I have the same issue. I added the second parameter (true) to load my CSS asynchronously and than my CSS did load in development. {{ craft.twigpack.includeCssModule("style.css", true) }}
However, it's still not in my production manifest.
There will be no styles.css
in your webserver-dev-builds
-- this is because the CSS is auto-inserted into the DOM via the css-loader
For the actual production build, the styles.css
will be in the manifest-legacy.json
as discussed in the article.
The reason for this is for it to be in both the modern manifest.json
as well as the manifest-legacy.json
would require rebuilding it twice; which would be slow, and relatively pointless.
I opted to do the build one, and put the results in the manifest-legacy.json
because we are compiling more modern CSS down to a legacy CSS (processed by PostCSS) that works on any browser.
If we ever reached the day where we had something akin to JavaScript ES6 Modules for CSS, then it might make sense to have a modern/legacy CSS bundle.
I suppose you could argue that we could do that now with the browserslist
but the gains seemed relatively small, and there's no neat correlation I can find to determine which CSS we should be loading for a given browser. There's no <style type="module">
or such to help us do it neatly, there way there is of JavaScript.
Hey Andrew,
Possibly an issue with my understanding here but I was expecting
manifest.json
to link to compiled styles, as it does withapp.js
. I believe this is why Twigpack may not be updating styles for me in dev (it is loading the file hashes seen in manifest-legacy.json instead), as they are not linked to in the manifest.Steps to reproduce:
yarn
,yarn build
,manifest.json
For me this file contains only:
Compared to
manifest-legacy.json
:Is this behaviour expected? Any light you can shed would be much appreciated. TIA.