Skip to content

Commit d2b3b8a

Browse files
committed
feat: customVariables
1 parent e46287d commit d2b3b8a

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,37 @@
3232

3333
## Module options
3434

35+
### `customVariables`
36+
- Type: `Array`
37+
- Items: `String`
38+
- Default: `[]`
39+
40+
Provide a way to customize Vuetify SASS variables.
41+
**Only works with [tree-shaking](#treeShake).**
42+
43+
Usage example :
44+
45+
```scss
46+
// assets/variables.scss
47+
@import '~vuetify/src/styles/styles.sass';
48+
49+
// The variables you want to modify
50+
$font-size-root: 14px;
51+
// For updating SASS lists
52+
$material-light: map-merge($material-light, ( cards: blue ));
53+
$btn-border-radius: 0px;
54+
```
55+
56+
```js
57+
// nuxt.config.js
58+
export default {
59+
vuetify: {
60+
customVariables: ['~/assets/variables.scss']
61+
}
62+
}
63+
```
64+
65+
3566
### `defaultAssets`
3667
- Type: `Object` or `Boolean`
3768
- Default:

lib/module.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const path = require('path')
22
const merge = require('deepmerge')
33

44
const defaults = {
5+
customVariables: [],
56
defaultAssets: {
67
font: true,
78
icons: true
@@ -32,6 +33,7 @@ module.exports = function (moduleOptions) {
3233
}
3334

3435
// Customize sass-loader options
36+
sassLoaderOptions.data = options.customVariables.map(path => `@import '${path}'`).join('\n')
3537
Object.assign(this.options.build.loaders.sass, sassLoaderOptions)
3638
Object.assign(this.options.build.loaders.scss, sassLoaderOptions)
3739

@@ -73,6 +75,7 @@ module.exports = function (moduleOptions) {
7375

7476
// Remove module options
7577
const vuetifyOptions = { ...options }
78+
delete vuetifyOptions.customVariables
7679
delete vuetifyOptions.defaultAssets
7780
delete vuetifyOptions.treeShake
7881

test/fixture/assets/variables.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$font-size-root: 20px;

test/fixture/nuxt.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports = {
1515
],
1616

1717
vuetify: {
18+
customVariables: ['~/assets/variables.scss'],
1819
theme: {
1920
dark: true,
2021
themes: {

0 commit comments

Comments
 (0)