You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+45-11
Original file line number
Diff line number
Diff line change
@@ -2,27 +2,27 @@
2
2
3
3
## js-to-styles-var-loader
4
4
5
-
### A [Webpack]() loader to share data for sass variables between javascript modules and sass files
5
+
### A [Webpack]() loader to share variable data between javascript modules and sass or less files
6
6
7
-
This loader is for that special case when you would like to import data from a javascript module into a sass file. The [sass loader](https://github.com/webpack-contrib/sass-loader) complains, because importing js module is not a valid sass instruction.
7
+
This loader is for that special case when you would like to import data from a javascript module into a sass /less file. The [sass](https://github.com/webpack-contrib/sass-loader)/ [less](http://lesscss.org/) loader complains, because importing js module is not a valid instruction.
8
8
9
-
##### The loader only handles the case when you want to inject sass variables into a sass file via a javascript module.
9
+
##### The loader only handles the case when you want to inject variable data into a sass / less file via a javascript module.
10
10
11
11
#### Prerequisites
12
12
13
13
- Nodejs >= 4.0
14
-
-[sass](http://sass-lang.com/) for css pre-processing
15
-
- Webpack for module bundle
14
+
- Webpack for module bundling
16
15
17
16
18
17
#### Setting up Webpack config
19
18
20
-
Probably you use [sass-loader](https://github.com/webpack-contrib/sass-loader) with Webpack. The usage in this case is pretty simple: just put this loader before sass-loader in your webpack config:
19
+
Probably you use [sass-loader](https://github.com/webpack-contrib/sass-loader)or [less-loader](https://github.com/webpack-contrib/less-loader)with Webpack. The usage in this case is pretty simple: just put the js-to-styles-var-loader before the sass-loader / less-loader in your webpack config:
21
20
21
+
For sass-loader:
22
22
```js
23
23
{
24
24
rules: [
25
-
test:/\.sass$/,
25
+
test:/\.scss$/,
26
26
use: [
27
27
{
28
28
loader:"style-loader"
@@ -34,13 +34,36 @@ Probably you use [sass-loader](https://github.com/webpack-contrib/sass-loader) w
34
34
loader:"sass-loader"
35
35
},
36
36
{
37
-
loader:"js-to-sass-var-loader"
37
+
loader:"js-to-styles-var-loader"
38
38
}
39
39
]
40
40
]
41
41
}
42
42
```
43
43
44
+
For less-loader:
45
+
46
+
```js
47
+
{
48
+
rules: [
49
+
test:/\.less$/,
50
+
use: [
51
+
{
52
+
loader:"style-loader"
53
+
},
54
+
{
55
+
loader:"css-loader"
56
+
},
57
+
{
58
+
loader:"less-loader"
59
+
},
60
+
{
61
+
loader:"js-to-styles-var-loader"
62
+
}
63
+
]
64
+
]
65
+
}
66
+
```
44
67
#### Usage
45
68
46
69
Let's assume we would like to store some variable data in a module like this:
0 commit comments