Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update storybook monorepo to v6 (major) #69

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"release": "yarn test && standard-version && yarn build && git push --follow-tags && npm publish"
},
"dependencies": {
"@storybook/addon-actions": "^5.3.19",
"@storybook/vue": "^5.3.19",
"@storybook/addon-actions": "^6.0.0",
"@storybook/vue": "^6.0.0",
"arg": "^4.1.3",
"babel-preset-vue": "^2.0.2",
"consola": "^2.15.0",
Expand Down
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,24 @@ async function getStorybookConfig (options: StorybookOptions) {
return config
}

if (!options.staticDir) {
options.staticDir = path.resolve(options.rootDir, nuxt.options.dir.static)
}
const staticDir = options.staticDir.split(',').map(dir => dir.trim())

return {
...vueOptions,
packageJson: require('../package.json'),
versionUpdates: false,
rootDir: options.rootDir,
configDir: nuxtStorybookConfig.configDir,
staticDir: [path.resolve(options.rootDir, nuxt.options.dir.static)],
port: process.env.PORT || nuxtStorybookConfig.port || 3003,
nuxt,
nuxtBuilder,
nuxtWebpackConfig,
nuxtStorybookConfig,
...options,
staticDir,
frameworkPresets: [
...vueOptions.frameworkPresets,
require.resolve('./preset')
Expand Down
11 changes: 11 additions & 0 deletions storybook/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import './mock'
// helpers to fix windows path
// https://github.com/nuxt/nuxt.js/blob/1edac29eba1a621339105f5adef73d4c30388fee/packages/utils/src/resolve.js#L13
export const isWindows = process.platform.startsWith('win')

export const wp = function wp (p = '') {
if (isWindows) {
return p.replace(/\\/g, '\\\\')
}
return p
}
10 changes: 5 additions & 5 deletions storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import Vue from 'vue'
import { wp } from '~storybook';

/* Styles */<% if (Array.isArray(options.styles)) { %>
<%= options.styles.map(s => `import '${s}'`).join("\n") %>
<%= options.styles.map(s => `import '${wp(s)}'`).join("\n") %>
<% } %>
import Vue from 'vue'
import { normalizeError } from '~~/.nuxt-storybook/utils'
import '~storybook/mock'
<% if (options.store) { %>import { createStore } from '~~/.nuxt-storybook/store'<% } %>
<% if (options.components) { %>import * as components from '~~/.nuxt-storybook/components';
Object.keys(components).forEach(name => Vue.component(name, components[name]))<% } %>
Expand All @@ -12,7 +13,7 @@ Object.keys(components).forEach(name => Vue.component(name, components[name]))<%
<% }) %>


const inject = (name, impl) => {
const inject = (name, impl) => {
Vue.prototype['$' + name] = impl
}
<% if (options.store) {%>inject('store', createStore({}))<% }%>
Expand All @@ -26,4 +27,3 @@ Vue.prototype.app = {};<% /* prevent undefined app exception */ %>
}
}
})

Loading