Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion packages/uniwind/src/metro/compileVirtual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { compile } from '@tailwindcss/node'
import { Scanner } from '@tailwindcss/oxide'
import path from 'path'
import { addMetaToStylesTemplate } from './addMetaToStylesTemplate'
import { Logger } from './logger'
import { polyfillWeb } from './polyfillWeb'
import { ProcessorBuilder } from './processor'
import { Platform, Polyfills } from './types'
Expand All @@ -13,9 +14,10 @@ type CompileVirtualConfig = {
platform: Platform
themes: Array<string>
polyfills: Polyfills | undefined
debug: boolean | undefined
}

export const compileVirtual = async ({ css, cssPath, platform, themes, polyfills }: CompileVirtualConfig) => {
export const compileVirtual = async ({ css, cssPath, platform, themes, polyfills, debug }: CompileVirtualConfig) => {
const compiler = await compile(css, {
base: path.dirname(cssPath),
onDependency: () => void 0,
Expand All @@ -38,6 +40,7 @@ export const compileVirtual = async ({ css, cssPath, platform, themes, polyfills

const Processor = new ProcessorBuilder(themes, polyfills)

Logger.debug = debug === true
Processor.transform(tailwindCSS)

const stylesheet = serializeJSObject(
Expand Down
1 change: 1 addition & 0 deletions packages/uniwind/src/metro/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type UniwindConfig = {
extraThemes?: Array<string>
dtsFile?: string
polyfills?: Polyfills
debug?: boolean
}

export declare function withUniwindConfig(config: MetroConfig, options: UniwindConfig): MetroConfig
14 changes: 14 additions & 0 deletions packages/uniwind/src/metro/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,31 @@ import chalk from 'chalk'

/* eslint-disable no-console */
export class Logger {
static debug = false

constructor(private readonly name: string) {}

static log(message: string, meta = '') {
if (!Logger.debug) {
return
}

console.log(chalk.cyan(`\nUniwind ${meta}- ${message}`))
}

static error(message: string, meta = '') {
if (!Logger.debug) {
return
}

console.log(chalk.red(`\nUniwind Error ${meta}- ${message}`))
}

static warn(message: string, meta = '') {
if (!Logger.debug) {
return
}

console.log(chalk.yellow(`\nUniwind Warning ${meta}- ${message}`))
}

Expand Down
1 change: 1 addition & 0 deletions packages/uniwind/src/metro/metro-transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const transform = async (
themes: config.uniwind.themes,
polyfills: config.uniwind.polyfills,
cssPath,
debug: config.uniwind.debug,
})
const isWeb = platform === Platform.Web

Expand Down
1 change: 1 addition & 0 deletions packages/uniwind/src/metro/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export type UniwindConfig = {
extraThemes?: Array<string>
dtsFile?: string
polyfills?: Polyfills
debug?: boolean
}

export type MediaQueryResolver = {
Expand Down