Skip to content

Commit f051849

Browse files
author
Andre Asselin
committed
Add documentation for custom sections
1 parent 972181c commit f051849

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

docs/en/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ There are many cool features provided by `vue-loader`:
1010

1111
- ES2015 enabled by default;
1212
- Allows using other Webpack loaders for each part of a Vue component, for example SASS for `<style>` and Jade for `<template>`;
13+
- Allows custom sections in a .vue file that can have custom loader chains applied to them
1314
- Treat static assets referenced in `<style>` and `<template>` as module dependencies and handle them with Webpack loaders;
1415
- Can simulate scoped CSS for each component;
1516
- Supports component hot-reloading during development.

docs/en/start/spec.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Vue Component Spec
22

3-
A `*.vue` file is a custom file format that uses HTML-like syntax to describe a Vue component. Each `*.vue` file consists of three types of top-level language blocks: `<template>`, `<script>` and `<style>`:
3+
A `*.vue` file is a custom file format that uses HTML-like syntax to describe a Vue component. Each `*.vue` file consists of three types of top-level language blocks: `<template>`, `<script>`, and `<style>`, and optionally additional custom blocks:
44

55
``` html
66
<template>
@@ -22,6 +22,10 @@ export default {
2222
color: red;
2323
}
2424
</style>
25+
26+
<custom1>
27+
This could be e.g. documentation for the component.
28+
</custom1>
2529
```
2630

2731
`vue-loader` will parse the file, extract each language block, pipe them through other loaders if necessary, and finally assemble them back into a CommonJS module whose `module.exports` is a Vue.js component options object.
@@ -66,6 +70,10 @@ More details can be found in [Using Pre-Processors](../configurations/pre-proces
6670

6771
- By default, contents will be extracted and dynamically inserted into the document's `<head>` as an actual `<style>` tag using `style-loader`. It's also possible to [configure Webpack so that all styles in all components are extracted into a single CSS file](../configurations/extract-css.md).
6872

73+
### Custom Language Blocks
74+
75+
Additional custom blocks can be included in a `*.vue` file for any project specific needs. `vue-loader` will use the tag name to look up which webpack loaders should be applied to the contents of the section. The webpack loaders should be specified in the `loaders` hash of the `vue` section of the webpack configuration in the same way that languages are specified for the standard sections of the file. See [Advanced Loader Configuration](../configurations/advanced.md).
76+
6977
### Src Imports
7078

7179
If you prefer splitting up your `*.vue` components into multiple files, you can use the `src` attribute to import an external file for a language block:

0 commit comments

Comments
 (0)