Skip to content
This repository was archived by the owner on Aug 16, 2022. It is now read-only.

feat: Change visibilty of compileStyle and compileTemplate methods to public #66

Merged
Merged
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
38 changes: 24 additions & 14 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ export class SFCCompiler {
const template =
descriptor.template && this.compileTemplate(filename, descriptor.template)

const styles = descriptor.styles.map(style => this.compileStyle(filename, scopeId, style))
const styles = descriptor.styles.map(style =>
this.compileStyle(filename, scopeId, style)
)

const { script: rawScript, customBlocks } = descriptor
const script = rawScript && {
Expand All @@ -113,7 +115,10 @@ export class SFCCompiler {
}
}

private compileTemplate(filename: string, template: SFCBlock) {
compileTemplate(
filename: string,
template: SFCBlock
): TemplateCompileResult & { functional: boolean } {
const { preprocessOptions, ...options } = this.template
const functional = 'functional' in template.attrs

Expand All @@ -136,18 +141,23 @@ export class SFCCompiler {
}
}

private compileStyle(filename: string, scopeId: string, style: SFCBlock) {
compileStyle(
filename: string,
scopeId: string,
style: SFCBlock
): StyleCompileResult {
let tokens = undefined
const needsCSSModules = style.module === true || typeof style.module === 'string'
const needsCSSModules =
style.module === true || typeof style.module === 'string'
const postcssPlugins = [
needsCSSModules
? postcssModules({
generateScopedName: '[path][local]-[hash:base64:4]',
...this.style.postcssModulesOptions,
getJSON: (t: any) => {
tokens = t
}
})
generateScopedName: '[path][local]-[hash:base64:4]',
...this.style.postcssModulesOptions,
getJSON: (t: any) => {
tokens = t
}
})
: undefined,
this.template.isProduction
? postcssClean(this.style.postcssCleanOptions)
Expand All @@ -165,10 +175,10 @@ export class SFCCompiler {
postcssOptions: this.style.postcssOptions,
preprocessLang: style.lang,
preprocessOptions:
(style.lang &&
this.style.preprocessOptions &&
this.style.preprocessOptions[style.lang]) ||
{},
(style.lang &&
this.style.preprocessOptions &&
this.style.preprocessOptions[style.lang]) ||
{},
trim: this.style.trim
})

Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy