Skip to content

Commit ea6ac4e

Browse files
authored
docs: Docs for RPV (vuejs#211)
* chore: Add docs structure * chore: Add docs build script * chore: Add yarn lock file * chore: Cleanup change log * chore: Fix typescript warning
1 parent 89839f2 commit ea6ac4e

27 files changed

+958
-2385
lines changed

CHANGELOG.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,6 @@ All notable changes to this project will be documented in this file. See [standa
3232
* Use named import querystring module ([#199](https://github.com/znck/rollup-plugin-vue/issues/199)) ([b3d63f0](https://github.com/znck/rollup-plugin-vue/commit/b3d63f0)), closes [#198](https://github.com/znck/rollup-plugin-vue/issues/198)
3333

3434

35-
36-
<a name="4.1.3"></a>
37-
## [4.1.3](https://github.com/znck/rollup-plugin-vue/compare/v4.1.2...v4.1.3) (2018-05-12)
38-
39-
40-
41-
<a name="4.1.2"></a>
42-
## [4.1.2](https://github.com/znck/rollup-plugin-vue/compare/v4.1.1...v4.1.2) (2018-05-12)
43-
44-
45-
4635
<a name="4.1.1"></a>
4736
## [4.1.1](https://github.com/znck/rollup-plugin-vue/compare/v4.1.0...v4.1.1) (2018-05-12)
4837

cookbook/minimal/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"build": "rollup -c --environment BUILD:production"
5+
},
6+
"main": "./dist/my-component.esm.js",
7+
"devDependencies": {
8+
"rollup": "^0.59.4",
9+
"rollup-plugin-vue": "link:../.."
10+
}
11+
}

cookbook/minimal/rollup.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import vue from 'rollup-plugin-vue'
2+
3+
export default {
4+
input: 'src/MyComponent.vue',
5+
output: {
6+
format: 'esm',
7+
file: 'dist/my-component.esm.js'
8+
},
9+
plugins: [
10+
vue()
11+
]
12+
}

cookbook/minimal/shrinkwrap.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
devDependencies:
2+
rollup: 0.59.4
3+
rollup-plugin-vue: 'link:../..'
4+
packages:
5+
/@types/estree/0.0.39:
6+
dev: true
7+
resolution:
8+
integrity: sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==
9+
/@types/node/10.3.0:
10+
dev: true
11+
resolution:
12+
integrity: sha512-hWzNviaVFIr1TqcRA8ou49JaSHp+Rfabmnqg2kNvusKqLhPU0rIsGPUj5WJJ7ld4Bb7qdgLmIhLfCD1qS08IVA==
13+
/rollup/0.59.4:
14+
dependencies:
15+
'@types/estree': 0.0.39
16+
'@types/node': 10.3.0
17+
dev: true
18+
resolution:
19+
integrity: sha512-ISiMqq/aJa+57QxX2MRcvLESHdJ7wSavmr6U1euMr+6UgFe6KM+3QANrYy8LQofwhTC1I7BcAdlLnDiaODs1BA==
20+
registry: 'https://registry.npmjs.org/'
21+
shrinkwrapMinorVersion: 7
22+
shrinkwrapVersion: 3
23+
specifiers:
24+
rollup: ^0.59.4
25+
rollup-plugin-vue: 'link:../..'

cookbook/minimal/src/MyComponent.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<template>
2+
<h1>Hello {{ name }}</h1>
3+
</template>
4+
5+
<script>
6+
export default {
7+
data() {
8+
return { name: 'Jane Doe' }
9+
}
10+
}
11+
</script>
12+
13+
<style scoped>
14+
h1 {
15+
color: red;
16+
}
17+
</style>

docs/.vuepress/config.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
module.exports = {
2+
title: 'Rollup Plugin Vue',
3+
description: 'Bundle .vue files using Rollup',
4+
markdown: {
5+
config(md) {
6+
md.use(require('./markdown-it-code-frame'))
7+
}
8+
},
9+
serviceWorker: true,
10+
themeConfig: {
11+
repo: 'vuejs/rollup-plugin-vue',
12+
editLinks: true,
13+
docsDir: 'docs',
14+
locales: {
15+
'/': {
16+
label: 'English',
17+
selectText: 'Languages',
18+
editLinkText: 'Edit this page on GitHub',
19+
nav: [{
20+
text: 'Guide',
21+
link: '/guide/'
22+
},
23+
{
24+
text: 'Options Reference',
25+
link: '/options'
26+
},
27+
{
28+
text: 'Migrating from v2',
29+
link: '/migrating'
30+
},
31+
{
32+
text: 'Cookbook',
33+
link: '/cookbook/'
34+
}
35+
],
36+
sidebar: [
37+
'/',
38+
'/guide/',
39+
'/options',
40+
'/cookbook/',
41+
'/changelog'
42+
]
43+
}
44+
}
45+
}
46+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
const fs = require('fs')
2+
3+
module.exports = function codeFrame(md, options = {}) {
4+
const root = options.root || process.cwd()
5+
function parser(state, startLine, endLine, silent) {
6+
const CH = '<'.charCodeAt(0)
7+
const pos = state.bMarks[startLine] + state.tShift[startLine]
8+
const max = state.eMarks[startLine]
9+
10+
// if it's indented more than 3 spaces, it should be a code block
11+
if (state.sCount[startLine] - state.blkIndent >= 4) {
12+
return false
13+
}
14+
15+
for (let i = 0; i < 3; ++i) {
16+
const ch = state.src.charCodeAt(pos + i)
17+
if (ch !== CH || pos + i >= max) return false
18+
}
19+
20+
if (silent) {
21+
return true
22+
}
23+
24+
const start = pos + 3
25+
const end = state.skipSpacesBack(max, pos)
26+
const rawPath = state.src.slice(start, end).trim().replace(/^@/, root)
27+
const filename = rawPath.split(/[{:\s]/).shift()
28+
const content = fs.existsSync(filename) ? fs.readFileSync(filename).toString() : 'Not found: ' + filename
29+
const meta = rawPath.replace(filename, '')
30+
31+
state.line = startLine + 1;
32+
33+
token = state.push('fence', 'code', 0)
34+
token.info = filename.split('.').pop() + meta
35+
token.content = content
36+
token.markup = '```'
37+
token.map = [startLine, startLine + 1]
38+
39+
return true
40+
}
41+
42+
md.block.ruler.before('fence', 'code-frame', parser)
43+
}
File renamed without changes.
File renamed without changes.

docs/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Introduction
2+
3+
:::warning
4+
This guide is work in progress.
5+
:::
6+
7+
:::tip VERSION NOTE
8+
This is the documentation for Rollup Plugin Vue v4 and above. If you are upgrading from v2 or an earlier version, check out the [Migration Guide](./migrating.md). If you are using an older version, the old docs are [here](https://github.com/vuejs/rollup-plugin-vue/tree/2.2/docs).
9+
:::
10+
11+
## What is Rollup Plugin Vue?
12+
13+
`rollup-plugin-vue` is a plugin for [rollup](https://rollupjs.org/) that allows you to author Vue components in a format called [Single-File Components (SFCs)](https://vue-loader.vuejs.org/spec.html):
14+
15+
``` vue
16+
<template>
17+
<div class="example">{{ msg }}</div>
18+
</template>
19+
20+
<script>
21+
export default {
22+
data () {
23+
return {
24+
msg: 'Hello world!'
25+
}
26+
}
27+
}
28+
</script>
29+
30+
<style>
31+
.example {
32+
color: red;
33+
}
34+
</style>
35+
```
36+
37+
There are many cool features provided by `rollup-plugin-vue`:
38+
39+
- Feature parity with [vue-loader](https://vue-loader.vuejs.org)
40+
- Allows custom blocks in a `.vue` file;
41+
- Treat static assets referenced in `<style>` and `<template>` as module dependencies;
42+
- Simulate scoped CSS for each component.
43+
44+
Rollup is a module bundler which makes `rollup-plugin-vue` ideal for packaging Vue plugins and UI component libraries.

0 commit comments

Comments
 (0)