Home / File/ stylePreprocessors.ts — vue Source File

stylePreprocessors.ts — vue Source File

Architecture documentation for stylePreprocessors.ts, a typescript file in the vue codebase. 3 imports, 1 dependents.

File typescript CompilerSFC StyleProcessor 3 imports 1 dependents 6 functions

Entity Profile

Dependency Diagram

graph LR
  496757ba_5cd7_a57b_2bda_c9d4086a452e["stylePreprocessors.ts"]
  846fe3a5_2ad8_8311_d2e5_7be0248ec102["merge-source-map"]
  496757ba_5cd7_a57b_2bda_c9d4086a452e --> 846fe3a5_2ad8_8311_d2e5_7be0248ec102
  0bf310ff_b73a_1898_7a5a_dca10146cbe0["source-map"]
  496757ba_5cd7_a57b_2bda_c9d4086a452e --> 0bf310ff_b73a_1898_7a5a_dca10146cbe0
  156bf2e1_8a13_f22d_5437_54f14bcef8fa["util"]
  496757ba_5cd7_a57b_2bda_c9d4086a452e --> 156bf2e1_8a13_f22d_5437_54f14bcef8fa
  028e31ce_07f6_d5b2_134a_c0b5bb64823a["compileStyle.ts"]
  028e31ce_07f6_d5b2_134a_c0b5bb64823a --> 496757ba_5cd7_a57b_2bda_c9d4086a452e
  style 496757ba_5cd7_a57b_2bda_c9d4086a452e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import merge from 'merge-source-map'
import { RawSourceMap } from 'source-map'
import { isFunction } from 'shared/util'

export type StylePreprocessor = (
  source: string,
  map: RawSourceMap | undefined,
  options: {
    [key: string]: any
    additionalData?: string | ((source: string, filename: string) => string)
    filename: string
  }
) => StylePreprocessorResults

export interface StylePreprocessorResults {
  code: string
  map?: object
  errors: Error[]
  dependencies: string[]
}

// .scss/.sass processor
const scss: StylePreprocessor = (source, map, options) => {
  const nodeSass = require('sass')
  const finalOptions = {
    ...options,
    data: getSource(source, options.filename, options.additionalData),
    file: options.filename,
    outFile: options.filename,
    sourceMap: !!map
  }

  try {
    const result = nodeSass.renderSync(finalOptions)
    const dependencies = result.stats.includedFiles
    if (map) {
      return {
        code: result.css.toString(),
        map: merge(map, JSON.parse(result.map.toString())),
        errors: [],
        dependencies
      }
    }

    return { code: result.css.toString(), errors: [], dependencies }
  } catch (e: any) {
    return { code: '', errors: [e], dependencies: [] }
  }
}

const sass: StylePreprocessor = (source, map, options) =>
  scss(source, map, {
    ...options,
    indentedSyntax: true
  })

// .less
const less: StylePreprocessor = (source, map, options) => {
  const nodeLess = require('less')

// ... (76 more lines)

Domain

Subdomains

Dependencies

  • merge-source-map
  • source-map
  • util

Frequently Asked Questions

What does stylePreprocessors.ts do?
stylePreprocessors.ts is a source file in the vue codebase, written in typescript. It belongs to the CompilerSFC domain, StyleProcessor subdomain.
What functions are defined in stylePreprocessors.ts?
stylePreprocessors.ts defines 6 function(s): StylePreprocessorResults, getSource, less, sass, scss, styl.
What does stylePreprocessors.ts depend on?
stylePreprocessors.ts imports 3 module(s): merge-source-map, source-map, util.
What files import stylePreprocessors.ts?
stylePreprocessors.ts is imported by 1 file(s): compileStyle.ts.
Where is stylePreprocessors.ts in the architecture?
stylePreprocessors.ts is located at packages/compiler-sfc/src/stylePreprocessors.ts (domain: CompilerSFC, subdomain: StyleProcessor, directory: packages/compiler-sfc/src).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free