Skip to content
This repository has been archived by the owner on Nov 5, 2020. It is now read-only.

Commit

Permalink
Merge pull request #121 from pocka/nits/use-vue-docgen-loader
Browse files Browse the repository at this point in the history
Deprecate custom loader
  • Loading branch information
pocka authored Nov 14, 2019
2 parents 83fc44c + bd57313 commit ce8b8ff
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 26 deletions.
33 changes: 8 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ Then register in `addons.js`.
import 'storybook-addon-vue-info/lib/register'
```

And setup custom webpack loader in order to extract component information with [vue-docgen-api](https://github.com/vue-styleguidist/vue-docgen-api).
And setup a webpack loader in order to extract component information with [vue-docgen-api](https://github.com/vue-styleguidist/vue-docgen-api).

```sh
npm install --save-dev vue-docgen-loader vue-docgen-api

# yarn add -D vue-docgen-loader vue-docgen-api
```

```js
// .storybook/webpack.config.js
Expand All @@ -59,7 +65,7 @@ And setup custom webpack loader in order to extract component information with [
module.exports = ({ config }) => {
config.module.rules.push({
test: /\.vue$/,
loader: 'storybook-addon-vue-info/loader',
loader: 'vue-docgen-loader',
enforce: 'post'
})

Expand Down Expand Up @@ -173,29 +179,6 @@ storiesOf('MyComponent', module)

For more detail, please take a look at [live example](https://storybook-addon-vue-info.netlify.com/?path=/story/examples-advance-usage--set-descriptions-manually).

### Loader options

You can pass options for vue-docgen-api through loader options (e.g. module alias).

```js
// .storybook/webpack.config.js

module.exports = ({ config }) => {
config.module.rules.push({
test: /\.vue$/,
loader: 'storybook-addon-vue-info/loader',
options: {
docgenOptions: {
// options for vue-docgen-api...
}
},
enforce: 'post'
})

return config
}
```

## Example

For real example, see `example` directory.
Expand Down
2 changes: 1 addition & 1 deletion example/.storybook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = ({ config }) => {

config.module.rules.push({
test: /\.vue$/,
loader: 'storybook-addon-vue-info/loader',
loader: 'vue-docgen-loader',
options: {
docgenOptions: {
alias: config.resolve.alias
Expand Down
2 changes: 2 additions & 0 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
"babel-preset-vue": "^2.0.2",
"highlight.js": "^9.14.1",
"marked": "^0.6.0",
"vue-docgen-api": "^3.26.0",
"vue-docgen-loader": "^1.0.0",
"vue-i18n": "^8.8.0",
"vue-loader": "^15.6.1",
"vue-template-compiler": "^2.5.22",
Expand Down
4 changes: 4 additions & 0 deletions loader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ const docgen = require('vue-docgen-api')
const loaderUtils = require('loader-utils')
const qs = require('querystring')

console.warn(
'storybook-addon-vue-info/loader is deprecated. Please consider using vue-docgen-loader instead.'
)

module.exports = function(content, map) {
const queries = qs.parse(this.resourceQuery.slice(1))

Expand Down

0 comments on commit ce8b8ff

Please sign in to comment.