mirror of
https://github.com/IT4Change/boilerplate-frontend.git
synced 2025-12-13 07:35:53 +00:00
Merge pull request #28 from IT4Change/import-order-sbcomp
refactor(frontend): import order + sbcomp + some types
This commit is contained in:
commit
6a6b7f0163
@ -135,15 +135,15 @@
|
|||||||
"vuepress": "^2.0.0-rc.0"
|
"vuepress": "^2.0.0-rc.0"
|
||||||
},
|
},
|
||||||
"imports": {
|
"imports": {
|
||||||
"#root/*": "./*",
|
|
||||||
"#src/*": "./src/*",
|
|
||||||
"#components/*": "./src/components/*",
|
"#components/*": "./src/components/*",
|
||||||
"#pages/*": "./src/pages/*",
|
"#pages/*": "./src/pages/*",
|
||||||
"#assets/*": "./src/assets/*",
|
"#assets/*": "./src/assets/*",
|
||||||
"#layouts/*": "./src/layouts/*",
|
"#layouts/*": "./src/layouts/*",
|
||||||
"#stores/*": "./src/stores/*",
|
"#stores/*": "./src/stores/*",
|
||||||
|
"#src/*": "./src/*",
|
||||||
"#plugins/*": "./renderer/plugins/*",
|
"#plugins/*": "./renderer/plugins/*",
|
||||||
"#context/*": "./renderer/context/*",
|
"#context/*": "./renderer/context/*",
|
||||||
"#types/*": "./types/*"
|
"#types/*": "./types/*",
|
||||||
|
"#root/*": "./*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,27 +52,29 @@ async function startServer() {
|
|||||||
|
|
||||||
// Vike middleware. It should always be our last middleware (because it's a
|
// Vike middleware. It should always be our last middleware (because it's a
|
||||||
// catch-all middleware superseding any middleware placed after it).
|
// catch-all middleware superseding any middleware placed after it).
|
||||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
app.get('*', (req, res, next) => {
|
||||||
app.get('*', async (req, res, next) => {
|
void (async (req, res, next) => {
|
||||||
const pageContextInit = {
|
const pageContextInit = {
|
||||||
urlOriginal: req.originalUrl,
|
urlOriginal: req.originalUrl,
|
||||||
}
|
}
|
||||||
const pageContext = await renderPage(pageContextInit)
|
const pageContext = await renderPage(pageContextInit)
|
||||||
const { httpResponse } = pageContext
|
const { httpResponse } = pageContext
|
||||||
if (!httpResponse) {
|
if (!httpResponse) {
|
||||||
return next()
|
next()
|
||||||
} else {
|
} else {
|
||||||
const { body, statusCode, headers, earlyHints } = httpResponse
|
const { body, statusCode, headers, earlyHints } = httpResponse
|
||||||
if (res.writeEarlyHints) res.writeEarlyHints({ link: earlyHints.map((e) => e.earlyHintLink) })
|
if (res.writeEarlyHints)
|
||||||
headers.forEach(([name, value]) => res.setHeader(name, value))
|
res.writeEarlyHints({ link: earlyHints.map((e) => e.earlyHintLink) })
|
||||||
res.status(statusCode)
|
headers.forEach(([name, value]) => res.setHeader(name, value))
|
||||||
// For HTTP streams use httpResponse.pipe() instead, see https://vike.dev/stream
|
res.status(statusCode)
|
||||||
res.send(body)
|
// For HTTP streams use httpResponse.pipe() instead, see https://vike.dev/stream
|
||||||
}
|
res.send(body)
|
||||||
|
}
|
||||||
|
})(req, res, next)
|
||||||
})
|
})
|
||||||
|
|
||||||
const port = process.env.PORT || 3000
|
const port = process.env.PORT || 3000
|
||||||
app.listen(port)
|
app.listen(port)
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(`Server running at http://localhost:${port}`)
|
console.log(`🚀 Server running at http://localhost:${port}`)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import { SBComp } from '#types/SBComp'
|
||||||
|
|
||||||
import ExampleButton from './ExampleButton.vue'
|
import ExampleButton from './ExampleButton.vue'
|
||||||
|
|
||||||
import type { Meta, StoryObj } from '@storybook/vue3'
|
import type { Meta, StoryObj } from '@storybook/vue3'
|
||||||
@ -5,8 +7,7 @@ import type { Meta, StoryObj } from '@storybook/vue3'
|
|||||||
// More on how to set up stories at: https://storybook.js.org/docs/vue/writing-stories/introduction
|
// More on how to set up stories at: https://storybook.js.org/docs/vue/writing-stories/introduction
|
||||||
const meta = {
|
const meta = {
|
||||||
title: 'Example/Button',
|
title: 'Example/Button',
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
component: ExampleButton as SBComp,
|
||||||
component: ExampleButton,
|
|
||||||
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/vue/writing-docs/autodocs
|
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/vue/writing-docs/autodocs
|
||||||
tags: ['autodocs'],
|
tags: ['autodocs'],
|
||||||
argTypes: {
|
argTypes: {
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import { SBComp } from '#types/SBComp'
|
||||||
|
|
||||||
import ExampleHeader from './ExampleHeader.vue'
|
import ExampleHeader from './ExampleHeader.vue'
|
||||||
|
|
||||||
import type { Meta, StoryObj } from '@storybook/vue3'
|
import type { Meta, StoryObj } from '@storybook/vue3'
|
||||||
@ -8,8 +10,7 @@ const meta = {
|
|||||||
* to learn how to generate automatic titles
|
* to learn how to generate automatic titles
|
||||||
*/
|
*/
|
||||||
title: 'Example/Header',
|
title: 'Example/Header',
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
component: ExampleHeader as SBComp,
|
||||||
component: ExampleHeader,
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
render: (args: any) => ({
|
render: (args: any) => ({
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||||
|
|||||||
@ -1,13 +1,14 @@
|
|||||||
import { within, userEvent } from '@storybook/testing-library'
|
import { within, userEvent } from '@storybook/testing-library'
|
||||||
|
|
||||||
|
import { SBComp } from '#types/SBComp'
|
||||||
|
|
||||||
import ExamplePage from './ExamplePage.vue'
|
import ExamplePage from './ExamplePage.vue'
|
||||||
|
|
||||||
import type { Meta, StoryObj } from '@storybook/vue3'
|
import type { Meta, StoryObj } from '@storybook/vue3'
|
||||||
|
|
||||||
const meta = {
|
const meta = {
|
||||||
title: 'Example/Page',
|
title: 'Example/Page',
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
component: ExamplePage as SBComp,
|
||||||
component: ExamplePage,
|
|
||||||
render: () => ({
|
render: () => ({
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||||
components: { ExamplePage },
|
components: { ExamplePage },
|
||||||
|
|||||||
@ -11,16 +11,16 @@
|
|||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"paths": {
|
"paths": {
|
||||||
"#root/*": ["./*"],
|
|
||||||
"#src/*": ["./src/*"],
|
|
||||||
"#components/*": ["./src/components/*"],
|
"#components/*": ["./src/components/*"],
|
||||||
"#pages/*": ["./src/pages/*"],
|
"#pages/*": ["./src/pages/*"],
|
||||||
"#assets/*": ["./src/assets/*"],
|
"#assets/*": ["./src/assets/*"],
|
||||||
"#layouts/*": ["./src/layouts/*"],
|
"#layouts/*": ["./src/layouts/*"],
|
||||||
"#stores/*": ["./src/stores/*"],
|
"#stores/*": ["./src/stores/*"],
|
||||||
|
"#src/*": ["./src/*"],
|
||||||
"#plugins/*": ["./renderer/plugins/*"],
|
"#plugins/*": ["./renderer/plugins/*"],
|
||||||
"#context/*": ["./renderer/context/*"],
|
"#context/*": ["./renderer/context/*"],
|
||||||
"#types/*": ["./types/*"]
|
"#types/*": ["./types/*"],
|
||||||
|
"#root/*": ["./*"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ts-node": {
|
"ts-node": {
|
||||||
|
|||||||
4
types/SBComp.ts
Normal file
4
types/SBComp.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
import { ConcreteComponent } from 'vue'
|
||||||
|
|
||||||
|
// Storybook Component Type
|
||||||
|
export type SBComp = Omit<ConcreteComponent<unknown>, 'props'>
|
||||||
@ -28,16 +28,16 @@ const config: UserConfig = {
|
|||||||
ssr: { noExternal: ['vuetify'] },
|
ssr: { noExternal: ['vuetify'] },
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
'#root': __dirname,
|
|
||||||
'#src': path.join(__dirname, '/src'),
|
|
||||||
'#components': path.join(__dirname, '/src/components'),
|
'#components': path.join(__dirname, '/src/components'),
|
||||||
'#pages': path.join(__dirname, '/src/pages'),
|
'#pages': path.join(__dirname, '/src/pages'),
|
||||||
'#assets': path.join(__dirname, '/src/assets'),
|
'#assets': path.join(__dirname, '/src/assets'),
|
||||||
'#layouts': path.join(__dirname, '/src/layouts'),
|
'#layouts': path.join(__dirname, '/src/layouts'),
|
||||||
'#stores': path.join(__dirname, '/src/stores'),
|
'#stores': path.join(__dirname, '/src/stores'),
|
||||||
|
'#src': path.join(__dirname, '/src'),
|
||||||
'#plugins': path.join(__dirname, '/renderer/plugins'),
|
'#plugins': path.join(__dirname, '/renderer/plugins'),
|
||||||
'#context': path.join(__dirname, '/renderer/context'),
|
'#context': path.join(__dirname, '/renderer/context'),
|
||||||
'#types': path.join(__dirname, '/types'),
|
'#types': path.join(__dirname, '/types'),
|
||||||
|
'#root': __dirname,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user