| | |
| | | import { joinStyles } from '../theme' |
| | | import { EmitCallback, PluginTypes } from './types' |
| | | import styles from '../styles/base.scss' |
| | | import { FilePath, ServerSlug } from '../path' |
| | | |
| | | export type ComponentResources = { |
| | | css: string[], |
| | |
| | | return scripts.map(script => `(function () {${script}})();`).join("\n") |
| | | } |
| | | |
| | | export async function emitComponentResources(cfg: GlobalConfiguration, res: ComponentResources, emit: EmitCallback): Promise<string[]> { |
| | | export async function emitComponentResources(cfg: GlobalConfiguration, res: ComponentResources, emit: EmitCallback): Promise<FilePath[]> { |
| | | const fps = await Promise.all([ |
| | | emit({ |
| | | slug: "index", |
| | | slug: "index" as ServerSlug, |
| | | ext: ".css", |
| | | content: joinStyles(cfg.theme, styles, ...res.css) |
| | | }), |
| | | emit({ |
| | | slug: "prescript", |
| | | slug: "prescript" as ServerSlug, |
| | | ext: ".js", |
| | | content: joinScripts(res.beforeDOMLoaded) |
| | | }), |
| | | emit({ |
| | | slug: "postscript", |
| | | slug: "postscript" as ServerSlug, |
| | | ext: ".js", |
| | | content: joinScripts(res.afterDOMLoaded) |
| | | }) |
| | |
| | | declare module 'vfile' { |
| | | // inserted in processors.ts |
| | | interface DataMap { |
| | | slug: string |
| | | allSlugs: string[] |
| | | filePath: string |
| | | slug: ServerSlug |
| | | allSlugs: ServerSlug[] |
| | | filePath: FilePath |
| | | } |
| | | } |