Coder Social home page Coder Social logo

vite-plugin-css-auto-import's People

Contributors

lunchbreakdev avatar malizhev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

vite-plugin-css-auto-import's Issues

Webpack support

Webpack still have a lot of users. Is there a plan of support of it?

Does not work on Windows

Thanks for this cool plugin, it would definitely be a time saver.

However on Windows, the current import logic does not work. The logic to lookup the styles for the virtual id expects the URL to start with a / and then some path, but on Windows, those absolute paths start with a drive identifier, e.g. C:/.

Css modules ignored when plugin passed next after solidjs plugin

Tested on [email protected] with [email protected]

vite.config.ts

import { defineConfig } from 'vite'
import solid from 'vite-plugin-solid'
import cssAutoImport from 'vite-plugin-css-auto-import';

export default defineConfig({
  plugins: [solid(), cssAutoImport()]
})

Example.tsx

export function Layout({ children }: ParentProps {
  return <div class="foo">{children}</div>;
}

Example.module.css

.foo {
  color: red
}

Rednered result

 <div class="foo">Hello world</div>
import { createHotContext as __vite__createHotContext } from "/@vite/client";import.meta.hot = __vite__createHotContext("/@id/__x00__virtual:css-auto-import/f75ed785fd956/originalModuleId=/home/experements/temp/src/example/Example.css");import { updateStyle as __vite__updateStyle, removeStyle as __vite__removeStyle } from "/@vite/client"
const __vite__id = "\u0000virtual:css-auto-import/f75ed785fd956/originalModuleId=/home/experements/temp/src/example/Example.css"
const __vite__css = "._foo_r1pu1_1 {\n  color: red\n}"
__vite__updateStyle(__vite__id, __vite__css)
import.meta.hot.accept()
export default __vite__css
import.meta.hot.prune(() => __vite__removeStyle(__vite__id))

But all works fine after next changes

export default defineConfig({
-  plugins: [solid(), cssAutoImport()]
+  plugins: [cssAutoImport(), solid()]
})

result:

<div class="_foo_r1pu1_1">Hello world</div>

Followup: Doesn't work on windows

Thanks for the fix in #1 , this definitely helped. However now SASS compilation fails during the import of those auto-imported scss files.

It can't find the @import-ed stylesheets that are referenced in my stylesheets using relative paths. So something about the working directory for sass compilation inside this plugin must be wrong i guess.

Example error message:

10:58:03 [vite] Internal server error: [sass] Can't find stylesheet to import.
  ╷
1 │ @import "../style/variables.scss";
  │         ^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
  virtual:css-auto-import\98ec907e6be21\originalModuleId=<stylesheet>.scss 1:9  root stylesheet

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.