MCPcopy
hub / github.com/vitejs/vite / createPreprocessorWorkerController

Function createPreprocessorWorkerController

packages/vite/src/node/plugins/css.ts:3158–3182  ·  view source on GitHub ↗
(maxWorkers: number | undefined)

Source from the content-addressed store, hash-verified

3156}
3157
3158const createPreprocessorWorkerController = (maxWorkers: number | undefined) => {
3159 const scss = scssProcessor(maxWorkers)
3160 const less = lessProcessor(maxWorkers)
3161 const styl = stylProcessor(maxWorkers)
3162
3163 const sassProcess: StylePreprocessor<SassStylePreprocessorInternalOptions>['process'] =
3164 (environment, source, root, options, resolvers) => {
3165 const opts: SassStylePreprocessorInternalOptions = { ...options }
3166 opts.syntax = 'indented'
3167 return scss.process(environment, source, root, opts, resolvers)
3168 }
3169
3170 const close = async () => {
3171 await Promise.all([less.close(), scss.close(), styl.close()])
3172 }
3173
3174 return {
3175 [PreprocessLang.less]: less.process,
3176 [PreprocessLang.scss]: scss.process,
3177 [PreprocessLang.sass]: sassProcess,
3178 [PreprocessLang.styl]: styl.process,
3179 [PreprocessLang.stylus]: styl.process,
3180 close,
3181 } as const satisfies Record<PreprocessLang | 'close', unknown>
3182}
3183
3184const normalizeMaxWorkers = (maxWorker: number | true | undefined) => {
3185 if (maxWorker === undefined) return 0

Callers 2

buildStartFunction · 0.85
preprocessCSSFunction · 0.85

Calls 3

scssProcessorFunction · 0.85
lessProcessorFunction · 0.85
stylProcessorFunction · 0.85

Tested by

no test coverage detected