Skip to content

Commit

Permalink
feat: support modern SASS api
Browse files Browse the repository at this point in the history
  • Loading branch information
ygj6 committed Mar 10, 2022
1 parent cd91163 commit b11bf7e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/playground/sass-modern/index.html
@@ -1,5 +1,7 @@
<div>
<p class="sass">SASS: This should be orange</p>
<p>Imported SASS string:</p>
<pre class="imported-sass"></pre>
<p class="css-dep-sass">
@import dependency w/ sass enrtrypoints: this should be orange
</p>
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/sass-modern/sass.scss
@@ -1,4 +1,4 @@
//@import 'css-dep'; // package w/ sass entry points
@import 'css-dep'; // package w/ sass entry points

.sass {
/* injected via vite.config.js */
Expand Down
5 changes: 3 additions & 2 deletions packages/vite/src/node/plugins/css.ts
Expand Up @@ -44,6 +44,7 @@ import type { Alias } from 'types/alias'
import type { ModuleNode } from '../server/moduleGraph'
import { transform, formatMessages } from 'esbuild'
import { addToHTMLProxyTransformResult } from './html'
import { pathToFileURL, fileURLToPath } from 'url'

// const debug = createDebugger('vite:css')

Expand Down Expand Up @@ -1114,7 +1115,7 @@ const scss: SassStylePreprocessor = async (

const finalOptions: Sass.StringOptions<'sync'> = {
...(options as Sass.StringOptions<'sync'>),
url: new URL(options.filename),
url: pathToFileURL(options.filename),
importers
}

Expand All @@ -1123,7 +1124,7 @@ const scss: SassStylePreprocessor = async (
await getSource(source, options.filename, options.additionalData),
finalOptions
)
const deps = result.loadedUrls.map((url) => url.pathname)
const deps = result.loadedUrls.map((url) => fileURLToPath(url))

return {
code: result.css,
Expand Down

0 comments on commit b11bf7e

Please sign in to comment.