diff --git a/CHANGELOG.md b/CHANGELOG.md index 3aa30a7..7e85d6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,17 +32,6 @@ All notable changes to this project will be documented in this file. See [standa * 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) - - -## [4.1.3](https://github.com/znck/rollup-plugin-vue/compare/v4.1.2...v4.1.3) (2018-05-12) - - - - -## [4.1.2](https://github.com/znck/rollup-plugin-vue/compare/v4.1.1...v4.1.2) (2018-05-12) - - - ## [4.1.1](https://github.com/znck/rollup-plugin-vue/compare/v4.1.0...v4.1.1) (2018-05-12) 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..fd650f8 --- /dev/null +++ b/docs/.vuepress/config.js @@ -0,0 +1,46 @@ +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/', + '/changelog' + ] + } + } + } +} \ 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 `