Skip to content

Commit ddd68d9

Browse files
committed
feat(styles): add sass option
1 parent 1957398 commit ddd68d9

File tree

12 files changed

+158
-20
lines changed

12 files changed

+158
-20
lines changed

dev/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
"css-loader": "^6.5.1",
2121
"pug": "^3.0.2",
2222
"pug-plain-loader": "^1.1.0",
23-
"sass-loader": "^12.4.0",
23+
"sass-loader": "^12.6.0",
2424
"url-loader": "^4.1.1",
25+
"vite-plugin-inspect": "^0.4.3",
2526
"vue-style-loader": "^4.1.3",
2627
"vuetify-loader": "^2.0.0-alpha.1",
2728
"webpack-cli": "^4.9.1",

dev/src/_variables.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
$color-pack: false;
2+
$alert-padding: 24px;
3+
$utilities: false;

dev/vite.config.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import vue from '@vitejs/plugin-vue'
22
import vuetify from '@vuetify/vite-plugin'
33
import path from 'path'
4+
import Inspect from 'vite-plugin-inspect'
45

56
export default {
67
root: path.resolve(__dirname, 'src'),
@@ -17,13 +18,26 @@ export default {
1718
})
1819
}
1920
}
20-
}
21+
},
22+
// Inspect(),
2123
],
2224
build: {
2325
outDir: '../dist',
2426
emptyOutDir: true,
2527
rollupOptions: {
2628
input: 'index.vite.html'
2729
}
30+
},
31+
resolve: {
32+
alias: {
33+
'@': __dirname
34+
},
35+
},
36+
css: {
37+
preprocessorOptions: {
38+
sass: {
39+
// additionalData: `@forward '@/src/_variables'\n`,
40+
}
41+
}
2842
}
2943
}

dev/webpack.config.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,19 @@ function sassLoaderOptions (indentedSyntax = false) {
1010
return {
1111
// implementation: require('sass'),
1212
// additionalData: `@import "~@/_variables.scss"` + (indentedSyntax ? '' : ';'),
13-
sassOptions: { indentedSyntax },
13+
api: 'modern',
14+
sassOptions: {
15+
indentedSyntax,
16+
// importers: [{
17+
// canonicalize (url) {
18+
// console.log(url)
19+
// return new URL(url)
20+
// },
21+
// load (url) {
22+
// console.log(url)
23+
// }
24+
// }]
25+
},
1426
}
1527
}
1628

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
"@vue/compiler-sfc": "^3.2.24",
1919
"conventional-changelog-conventionalcommits": "^4.6.1",
2020
"lerna": "^3.22.1",
21-
"sass": "^1.44.0",
21+
"sass": "^1.49.9",
2222
"typescript": "^4.4.2",
2323
"vite": "^2.7.1",
2424
"vue": "^3.2.19",
2525
"vue-loader": "^16.5.0",
26-
"vuetify": "^3.0.0-alpha.11",
26+
"vuetify": "npm:@vuetify/nightly@next",
2727
"webpack": "^5.65.0"
2828
}
2929
}

packages/shared/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export interface Options {
22
autoImport?: importPluginOptions,
3-
styles?: true | 'none' | 'expose',
3+
styles?: true | 'none' | 'expose' | 'sass',
44
/** @internal Only for testing */
55
stylesTimeout?: number
66
}

packages/vite-plugin/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,14 @@ import { createVuetify } from 'vuetify'
6464

6565
export default createVuetify()
6666
```
67+
68+
### Import sass from source
69+
Vuetify 3 uses precompiled css by default, these imports can optionally be modified to point to sass files instead:
70+
71+
```js
72+
// vite.config.js
73+
plugins: [
74+
vue(),
75+
vuetify({ styles: 'sass' }),
76+
]
77+
```

packages/vite-plugin/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export = function vuetify (_options: Options = {}) {
1616
if (options.autoImport) {
1717
plugins.push(importPlugin())
1818
}
19-
if (options.styles === 'none' || options.styles === 'expose') {
19+
if (options.styles === 'none' || options.styles === 'expose' || options.styles === 'sass') {
2020
plugins.push(stylesPlugin(options))
2121
}
2222

packages/vite-plugin/src/stylesPlugin.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ export function stylesPlugin (options: Options): PluginOption {
132132
) {
133133
if (options.styles === 'none') {
134134
return '\0__void__'
135+
} else if (options.styles === 'sass') {
136+
return source.replace(/\.css$/, '.sass')
135137
} else if (options.styles === 'expose') {
136138
awaitResolve()
137139

packages/vuetify-loader/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,19 @@ import { createVuetify } from 'vuetify'
111111
export default createVuetify()
112112
```
113113

114+
### Import sass from source
115+
Vuetify 3 uses precompiled css by default, these imports can optionally be modified to point to sass files instead:
116+
117+
```js
118+
// webpack.config.js
119+
const { VuetifyLoaderPlugin } = require('vuetify-loader')
120+
121+
module.exports = {
122+
plugins: [
123+
new VuetifyLoaderPlugin({ styles: 'sass' }),
124+
],
125+
}
126+
```
127+
114128
## Progressive images
115129
Coming soon...

0 commit comments

Comments
 (0)