Skip to content
This repository was archived by the owner on Dec 26, 2018. It is now read-only.

Commit 5f1cf6a

Browse files
committed
add docs for css extraction
1 parent 98ec0b2 commit 5f1cf6a

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

README.md

+24-3
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ browserify('./main.js')
224224
.pipe(fs.createWriteStream("bundle.js"))
225225
```
226226

227-
### Scoped CSS
227+
## Scoped CSS
228228

229229
When a `<style>` tag has the `scoped` attribute, its CSS will apply to elements of the current component only. This is similar to the style encapsulation found in Shadow DOM, but doesn't require any polyfills. It is achieved by transforming the following:
230230

@@ -252,15 +252,15 @@ Into the following:
252252
</template>
253253
```
254254

255-
#### Notes
255+
### Scoped CSS Notes
256256

257257
1. You can include both scoped and non-scoped styles in the same component.
258258

259259
2. The following will be affected by both the parent's scoped CSS and the child's scoped CSS:
260260
- A child component's root node
261261
- Content inserted to a child component via `<slot>`
262262

263-
### Hot Reload
263+
## Hot Reload
264264

265265
To enable hot component reloading, you need to install the [browserify-hmr](https://github.com/AgentME/browserify-hmr) plugin:
266266

@@ -271,6 +271,27 @@ watchify -p browserify-hmr index.js -o bundle.js
271271

272272
You can scaffold a hot-reload enabled project easily using `vue-cli` and the [this template](https://github.com/vuejs-templates/browserify-simple-2.0).
273273

274+
## CSS Extraction
275+
276+
By default, the CSS in each component is injected into the page using a `<style>` tag. This works well in most scenarios and enables CSS hot-reloading during development. However, in some cases you may prefer extracting all component CSS into a single file for better performance. To do that, you will need to add the CSS extraction browserify plugin.
277+
278+
Via CLI:
279+
280+
``` bash
281+
browserify -t vueify -p [ vueify/plugins/extract-css -o dist/bundle.css ] main.js
282+
```
283+
284+
Via API:
285+
286+
``` js
287+
browserify('./main.js')
288+
.transform('vueify')
289+
.plugin('vueify/plugins/extract-css', {
290+
out: 'dist/bundle.css'
291+
})
292+
.bundle()
293+
```
294+
274295
## Compiler API
275296

276297
The compiler API (originally `vue-component-compiler`) is also exposed:

0 commit comments

Comments
 (0)