From b4c5f34bbe52b2f4641f55b6dd4831606fbc9454 Mon Sep 17 00:00:00 2001 From: Rahul Kadyan Date: Mon, 4 Jun 2018 22:08:59 +0530 Subject: [PATCH 1/5] chore: Add docs structure --- cookbook/minimal/package.json | 11 + cookbook/minimal/rollup.config.js | 12 + cookbook/minimal/shrinkwrap.yaml | 25 + cookbook/minimal/src/MyComponent.vue | 17 + docs/.vuepress/config.js | 45 + docs/.vuepress/markdown-it-code-frame.js | 43 + docs/{ => .vuepress/public}/.nojekyll | 0 logo.png => docs/.vuepress/public/logo.png | Bin docs/README.md | 44 + docs/assets/css/main.css | 865 --- docs/assets/css/main.css.map | 7 - docs/assets/images/icons.png | Bin 9487 -> 0 bytes docs/assets/images/icons@2x.png | Bin 27740 -> 0 bytes docs/assets/images/widgets.png | Bin 480 -> 0 bytes docs/assets/images/widgets@2x.png | Bin 855 -> 0 bytes docs/assets/js/main.js | 5 - docs/assets/js/search.js | 3 - docs/cookbook/README.md | 9 + docs/globals.html | 221 - docs/guide/README.md | 14 + docs/index.html | 190 - docs/interfaces/vuepluginoptions.html | 470 -- docs/migrating.md | 1 + docs/options.md | 165 + yarn.lock | 5582 -------------------- 25 files changed, 386 insertions(+), 7343 deletions(-) create mode 100644 cookbook/minimal/package.json create mode 100644 cookbook/minimal/rollup.config.js create mode 100644 cookbook/minimal/shrinkwrap.yaml create mode 100644 cookbook/minimal/src/MyComponent.vue create mode 100644 docs/.vuepress/config.js create mode 100644 docs/.vuepress/markdown-it-code-frame.js rename docs/{ => .vuepress/public}/.nojekyll (100%) rename logo.png => docs/.vuepress/public/logo.png (100%) create mode 100644 docs/README.md delete mode 100644 docs/assets/css/main.css delete mode 100644 docs/assets/css/main.css.map delete mode 100644 docs/assets/images/icons.png delete mode 100644 docs/assets/images/icons@2x.png delete mode 100644 docs/assets/images/widgets.png delete mode 100644 docs/assets/images/widgets@2x.png delete mode 100644 docs/assets/js/main.js delete mode 100644 docs/assets/js/search.js create mode 100644 docs/cookbook/README.md delete mode 100644 docs/globals.html create mode 100644 docs/guide/README.md delete mode 100644 docs/index.html delete mode 100644 docs/interfaces/vuepluginoptions.html create mode 100644 docs/migrating.md create mode 100644 docs/options.md delete mode 100644 yarn.lock diff --git a/cookbook/minimal/package.json b/cookbook/minimal/package.json new file mode 100644 index 0000000..b8e70a3 --- /dev/null +++ b/cookbook/minimal/package.json @@ -0,0 +1,11 @@ +{ + "private": true, + "scripts": { + "build": "rollup -c --environment BUILD:production" + }, + "main": "./dist/my-component.esm.js", + "devDependencies": { + "rollup": "^0.59.4", + "rollup-plugin-vue": "link:../.." + } +} diff --git a/cookbook/minimal/rollup.config.js b/cookbook/minimal/rollup.config.js new file mode 100644 index 0000000..240d4f1 --- /dev/null +++ b/cookbook/minimal/rollup.config.js @@ -0,0 +1,12 @@ +import vue from 'rollup-plugin-vue' + +export default { + input: 'src/MyComponent.vue', + output: { + format: 'esm', + file: 'dist/my-component.esm.js' + }, + plugins: [ + vue() + ] +} diff --git a/cookbook/minimal/shrinkwrap.yaml b/cookbook/minimal/shrinkwrap.yaml new file mode 100644 index 0000000..e2a1af8 --- /dev/null +++ b/cookbook/minimal/shrinkwrap.yaml @@ -0,0 +1,25 @@ +devDependencies: + rollup: 0.59.4 + rollup-plugin-vue: 'link:../..' +packages: + /@types/estree/0.0.39: + dev: true + resolution: + integrity: sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw== + /@types/node/10.3.0: + dev: true + resolution: + integrity: sha512-hWzNviaVFIr1TqcRA8ou49JaSHp+Rfabmnqg2kNvusKqLhPU0rIsGPUj5WJJ7ld4Bb7qdgLmIhLfCD1qS08IVA== + /rollup/0.59.4: + dependencies: + '@types/estree': 0.0.39 + '@types/node': 10.3.0 + dev: true + resolution: + integrity: sha512-ISiMqq/aJa+57QxX2MRcvLESHdJ7wSavmr6U1euMr+6UgFe6KM+3QANrYy8LQofwhTC1I7BcAdlLnDiaODs1BA== +registry: 'https://registry.npmjs.org/' +shrinkwrapMinorVersion: 7 +shrinkwrapVersion: 3 +specifiers: + rollup: ^0.59.4 + rollup-plugin-vue: 'link:../..' diff --git a/cookbook/minimal/src/MyComponent.vue b/cookbook/minimal/src/MyComponent.vue new file mode 100644 index 0000000..9d14df0 --- /dev/null +++ b/cookbook/minimal/src/MyComponent.vue @@ -0,0 +1,17 @@ + + + + + diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js new file mode 100644 index 0000000..36f5837 --- /dev/null +++ b/docs/.vuepress/config.js @@ -0,0 +1,45 @@ +module.exports = { + title: 'Rollup Plugin Vue', + description: 'Bundle .vue files using Rollup', + markdown: { + config(md) { + md.use(require('./markdown-it-code-frame')) + } + }, + serviceWorker: true, + themeConfig: { + repo: 'vuejs/rollup-plugin-vue', + editLinks: true, + docsDir: 'docs', + locales: { + '/': { + label: 'English', + selectText: 'Languages', + editLinkText: 'Edit this page on GitHub', + nav: [{ + text: 'Guide', + link: '/guide/' + }, + { + text: 'Options Reference', + link: '/options' + }, + { + text: 'Migrating from v2', + link: '/migrating' + }, + { + text: 'Cookbook', + link: '/cookbook/' + } + ], + sidebar: [ + '/', + '/guide/', + '/options', + '/cookbook/' + ] + } + } + } +} \ No newline at end of file diff --git a/docs/.vuepress/markdown-it-code-frame.js b/docs/.vuepress/markdown-it-code-frame.js new file mode 100644 index 0000000..3b75d2c --- /dev/null +++ b/docs/.vuepress/markdown-it-code-frame.js @@ -0,0 +1,43 @@ +const fs = require('fs') + +module.exports = function codeFrame(md, options = {}) { + const root = options.root || process.cwd() + function parser(state, startLine, endLine, silent) { + const CH = '<'.charCodeAt(0) + const pos = state.bMarks[startLine] + state.tShift[startLine] + const max = state.eMarks[startLine] + + // if it's indented more than 3 spaces, it should be a code block + if (state.sCount[startLine] - state.blkIndent >= 4) { + return false + } + + for (let i = 0; i < 3; ++i) { + const ch = state.src.charCodeAt(pos + i) + if (ch !== CH || pos + i >= max) return false + } + + if (silent) { + return true + } + + const start = pos + 3 + const end = state.skipSpacesBack(max, pos) + const rawPath = state.src.slice(start, end).trim().replace(/^@/, root) + const filename = rawPath.split(/[{:\s]/).shift() + const content = fs.existsSync(filename) ? fs.readFileSync(filename).toString() : 'Not found: ' + filename + const meta = rawPath.replace(filename, '') + + state.line = startLine + 1; + + token = state.push('fence', 'code', 0) + token.info = filename.split('.').pop() + meta + token.content = content + token.markup = '```' + token.map = [startLine, startLine + 1] + + return true + } + + md.block.ruler.before('fence', 'code-frame', parser) +} diff --git a/docs/.nojekyll b/docs/.vuepress/public/.nojekyll similarity index 100% rename from docs/.nojekyll rename to docs/.vuepress/public/.nojekyll diff --git a/logo.png b/docs/.vuepress/public/logo.png similarity index 100% rename from logo.png rename to docs/.vuepress/public/logo.png diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..4e9b49d --- /dev/null +++ b/docs/README.md @@ -0,0 +1,44 @@ +# Introduction + +:::warning +This guide is work in progress. +::: + +:::tip VERSION NOTE +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). +::: + +## What is Rollup Plugin Vue? + +`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): + +``` vue + + + + + +``` + +There are many cool features provided by `rollup-plugin-vue`: + +- Feature parity with [vue-loader](https://vue-loader.vuejs.org) +- Allows custom blocks in a `.vue` file; +- Treat static assets referenced in `