mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
configure storybook to load BaseComponents and svgs
This commit is contained in:
parent
0727c3314d
commit
03eb32131c
@ -22,8 +22,19 @@ Vue.component('v-popover', {
|
|||||||
template: '<div><slot>Popover Content</slot></div>',
|
template: '<div><slot>Popover Content</slot></div>',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Globally register base components
|
||||||
|
const componentFiles = require.context('../components/_new/generic', true, /Base[a-zA-Z]+\.vue/)
|
||||||
|
|
||||||
|
componentFiles.keys().forEach(fileName => {
|
||||||
|
const component = componentFiles(fileName)
|
||||||
|
const componentConfig = component.default || component
|
||||||
|
const componentName = component.name || fileName.replace(/^.+\//, '').replace('.vue', '')
|
||||||
|
|
||||||
|
Vue.component(componentName, componentConfig)
|
||||||
|
})
|
||||||
|
|
||||||
// Setup design token addon
|
// Setup design token addon
|
||||||
const scssReq = require.context('!!raw-loader!~/view/styles', true, /.\.scss$/)
|
const scssReq = require.context('!!raw-loader!~/assets/_new/styles', true, /.\.scss$/)
|
||||||
const scssTokenFiles = scssReq
|
const scssTokenFiles = scssReq
|
||||||
.keys()
|
.keys()
|
||||||
.map(filename => ({ filename, content: scssReq(filename).default }))
|
.map(filename => ({ filename, content: scssReq(filename).default }))
|
||||||
|
|||||||
@ -32,6 +32,30 @@ module.exports = async ({ config, mode }) => {
|
|||||||
include: path.resolve(__dirname, '../'),
|
include: path.resolve(__dirname, '../'),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// load svgs with vue-svg-loader instead of file-loader
|
||||||
|
let rule = config.module.rules.find(
|
||||||
|
r =>
|
||||||
|
r.test && r.test.toString().includes('svg') && r.loader && r.loader.includes('file-loader'),
|
||||||
|
)
|
||||||
|
rule.test = /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|cur|ani)(\?.*)?$/
|
||||||
|
|
||||||
|
config.module.rules.push({
|
||||||
|
test: /\.svg$/,
|
||||||
|
loader: 'vue-svg-loader',
|
||||||
|
options: {
|
||||||
|
svgo: {
|
||||||
|
plugins: [
|
||||||
|
{
|
||||||
|
removeViewBox: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
removeDimensions: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
config.resolve.alias = {
|
config.resolve.alias = {
|
||||||
...config.resolve.alias,
|
...config.resolve.alias,
|
||||||
'~~': path.resolve(__dirname, rootDir),
|
'~~': path.resolve(__dirname, rootDir),
|
||||||
|
|||||||
@ -1,6 +1,3 @@
|
|||||||
// import fs from 'fs'
|
|
||||||
// import path from 'path'
|
|
||||||
|
|
||||||
import { createLocalVue } from '@vue/test-utils'
|
import { createLocalVue } from '@vue/test-utils'
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
import VTooltip from 'v-tooltip'
|
import VTooltip from 'v-tooltip'
|
||||||
@ -17,14 +14,3 @@ global.localVue.use(Styleguide)
|
|||||||
global.localVue.use(BaseComponents)
|
global.localVue.use(BaseComponents)
|
||||||
global.localVue.use(Filters)
|
global.localVue.use(Filters)
|
||||||
global.localVue.use(InfiniteScroll)
|
global.localVue.use(InfiniteScroll)
|
||||||
|
|
||||||
// // import BaseComponents without require.context for tests
|
|
||||||
// const componentFiles = fs
|
|
||||||
// .readdirSync(path.join(__dirname, 'components/_new/generic/'))
|
|
||||||
// .filter(fileName => /Base[a-zA-Z]+\.vue/.test(fileName))
|
|
||||||
|
|
||||||
// componentFiles.forEach(fileName => {
|
|
||||||
// const componentName = fileName.replace(/^.+\//, '').replace('.vue', '')
|
|
||||||
// const componentConfig = require('~/components/_new/generic/' + fileName)
|
|
||||||
// global.localVue.component(componentName, componentConfig.default || componentConfig)
|
|
||||||
// })
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user