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
{{ message }}
This repository was archived by the owner on Jan 18, 2022. It is now read-only.
[Node][node] and [Rollup][rollup] are required to use rollup-plugin-vue. Use [NPM][NPM] or [yarn][yarn] to add `rollup-plugin-vue` as development dependency to your project.
8
8
9
-
### Using NPM
9
+
#####Using NPM
10
10
```
11
11
npm install --save-dev rollup-plugin-vue
12
12
```
13
13
14
-
### Using yarn
14
+
#####Using yarn
15
15
```
16
16
yarn add --dev rollup-plugin-vue
17
17
```
18
18
19
-
### Use plugin
19
+
#####Use plugin
20
20
Next add `rollup-plugin-vue` to `rollup` plugins.
21
21
22
22
```js
@@ -25,7 +25,7 @@ import vue from 'rollup-plugin-vue';
25
25
26
26
exportdefault {
27
27
plugins: [
28
-
vue(),
28
+
vue({ /* configuration options. */ }),
29
29
],
30
30
};
31
31
```
@@ -84,10 +84,16 @@ List of supported style languages:
84
84
The default style language.
85
85
86
86
- ##### Sass/Scss
87
-
It uses `node-sass@^4.5.0` to process`sass/scss` style elements. You can provide `node-sass` configuration options by ```scss: { /* node-sass options */}```.
87
+
It uses `node-sass@^4.5.0` to process`sass/scss` style elements. You can provide `node-sass` configuration options by setting:
88
+
``` js
89
+
scss: { /* node-sass options */}
90
+
```
88
91
89
92
- ##### Less
90
-
It uses `less@^2.7.2` to process`less` style elements. You can provide `less` configuration options by ```less: { /* node-sass options */}```.
93
+
It uses `less@^2.7.2` to process`less` style elements. You can provide `less` configuration options by setting:
94
+
``` js
95
+
less: { /* node-sass options */}
96
+
```
91
97
92
98
<p class="tip" markdown="1">
93
99
`node-sass` and `less` are optional dependencies. If you are using `scss/sass/less` you should require (`yarn add --dev node-sass less`) them.
@@ -112,29 +118,124 @@ export default {
112
118
```
113
119
114
120
#### CSS Modules
121
+
[CSS Modules](https://github.com/css-modules/css-modules) is a popular system for modularizing and composing CSS. `rollup-plugin-vue` provides first-class integration with CSS Modules as an alternative for simulated scoped CSS.
122
+
123
+
``` vue
124
+
<style module>
125
+
.red {
126
+
color: red;
127
+
}
128
+
129
+
.bold {
130
+
font-weight: bold;
131
+
}
132
+
</style>
133
+
134
+
<template>
135
+
<div>
136
+
<p :class="{ [$style.red]: isRed }">
137
+
Am I red?
138
+
</p>
139
+
140
+
<p :class="[$style.red, $style.bold]">
141
+
Red and bold
142
+
</p>
143
+
</div>
144
+
</template>
145
+
146
+
<script>
147
+
export default {
148
+
computed: {
149
+
150
+
$style () {
151
+
return this.$options.cssModules
152
+
}
153
+
154
+
}
155
+
}
156
+
</script>
157
+
```
158
+
159
+
<p class="tip">
160
+
`rollup-plugin-vue@^2.3` cannot add `$style` computed property. You have to explcitly add it.
161
+
</p>
162
+
163
+
``` js
164
+
$style () {
165
+
return this.$options.cssModules
166
+
}
167
+
```
168
+
169
+
##### Custom Inject Name
170
+
You can have more than one `<style>` tags in a single *.vuecomponent. To avoid injected styles to overwrite each other, you can customize the name of the injected computed property by giving the module attribute a value:
115
171
172
+
```
173
+
<style module="a">
174
+
/* identifiers injected as a */
175
+
</style>
176
+
177
+
<style module="b">
178
+
/* identifiers injected as b */
179
+
</style>
180
+
```
181
+
##### CSS Modules Configuration
182
+
`rollup-plugin-vue` uses `postcss-modules` to handle CSS modules.
183
+
184
+
You can provide `postcss-modules` configuration options by setting:
0 commit comments