CSS is missed in `transform` hook
See original GitHub issueDescribe the bug
CSS is missed in transform
hook now.
code
argument of transform(code, id)
hook contains only "export default ''"
string. There is no CSS.
It worked before — with Vite 2.5.7.
For example, I was able to generate such style.css
With this plugin: (using), (plugin code)
For the reproduction uncomment these lines of the minimal reproduction repo
Reproduction
https://github.com/AlttiRi/serve-json-gz-length-test
System Info
OS: Windows 10 10.0.19043
Node: 17.3.0
Yarn: 1.22.5
npm: 7.19.1
vite: 2.7.2
Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
CSS ::before and ::after for custom animations and transitions
Learn how to create gorgeous custom animations and transitions using CSS ::before and ::after pseudo-elements, box shadows, and more.
Read more >babel-plugin-css-modules-transform - npm package - Snyk
Looks like babel-plugin-css-modules-transform is missing a security policy. ... This plugin is based on the fantastic css-modules-require-hook.
Read more >A Complete Guide to CSS Functions
Like any other programming language, CSS has functions. ... selectors are incredibly versatile, yet often overlooked and under-appreciated.
Read more >Using useRef hook, modify CSS style for a react component
You should instead go for state and CSS classes. State determines the element's classes which ultimately determines the style of the element. – ......
Read more >FAQs - styled-components
New hooks-based component model ... Note regarding css @import and createGlobalStyle ... Missing Declarations for styled-components/native?
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The bug appeared with Vite 2.6.0.
With “~2.5.10” it works OK.
With the latest Vite (3.2.4) while this issue is still actual, I can handle CSS:
transform
hook should be used as a Vite’s pluginbuild.cssCodeSplit
should befalse
In this case it works with minor changes:
index.html
index.css
, notstyle.css
I use the plugin to generate such CSS: https://alttiri.github.io/file-manager-snapshot-explorer/index.css
Because Vite.js still does not support SourceMaps for CSS. https://github.com/vitejs/vite/issues/2830