Skip to content

Commit

Permalink
Update build command to use pnpm and enable watch mode
Browse files Browse the repository at this point in the history
  • Loading branch information
1aron committed Feb 22, 2024
1 parent 1fc5e44 commit 49d440d
Show file tree
Hide file tree
Showing 20 changed files with 51 additions and 26 deletions.
2 changes: 1 addition & 1 deletion examples/svelte-with-static-extraction/src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<body data-sveltekit-preload-data="hover" class="fuck">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>
2 changes: 1 addition & 1 deletion packages/class-variant/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "class-variant",
"scripts": {
"build": "techor build",
"dev": "techor dev",
"dev": "pnpm build --watch",
"type-check": "tsc --noEmit",
"lint": "eslint src",
"test": "jest"
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@master/css-cli",
"scripts": {
"build": "techor build",
"dev": "techor dev",
"dev": "pnpm build --watch",
"lint": "eslint ./src",
"type-check": "tsc --noEmit",
"test": "jest"
Expand Down
2 changes: 1 addition & 1 deletion packages/create/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "module",
"scripts": {
"build": "techor build",
"dev": "techor dev",
"dev": "pnpm build --watch",
"lint": "eslint ./src",
"type-check": "tsc --noEmit",
"test": "jest"
Expand Down
2 changes: 1 addition & 1 deletion packages/css/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "module",
"scripts": {
"build": "techor build \"src/**/*.ts\"",
"dev": "techor dev",
"dev": "pnpm build --watch",
"test": "jest",
"type-check": "tsc --noEmit",
"lint": "eslint src"
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@master/eslint-plugin-css",
"scripts": {
"build": "techor build \"src/**/*.ts\"",
"dev": "techor dev",
"dev": "pnpm build --watch",
"test": "jest",
"type-check": "tsc --noEmit",
"lint": "eslint src"
Expand Down
2 changes: 1 addition & 1 deletion packages/extractor.vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "module",
"scripts": {
"build": "techor build \"src/**/*.ts\"",
"dev": "techor dev",
"dev": "pnpm build --watch",
"type-check": "tsc --noEmit",
"lint": "eslint src",
"test": "jest --workerThreads"
Expand Down
2 changes: 1 addition & 1 deletion packages/extractor.webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@master/css-extractor.webpack",
"scripts": {
"build": "techor build \"src/**/*.ts\"",
"dev": "techor dev",
"dev": "pnpm build --watch",
"type-check": "tsc --noEmit",
"lint": "eslint src"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/extractor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@master/css-extractor",
"scripts": {
"build": "techor build \"src/**/*.ts\"",
"dev": "techor dev",
"dev": "techor build --watch",
"lint": "eslint ./src",
"type-check": "tsc --noEmit",
"test": "jest"
Expand Down
37 changes: 31 additions & 6 deletions packages/extractor/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { default as defaultOptions, Options } from './options'
import { MasterCSS } from '@master/css'
import type { Config } from '@master/css'
import extractLatentClasses from './functions/extract-latent-classes'
import fs from 'fs'
import fs, { existsSync } from 'fs'
import { minimatch } from 'minimatch'
import log from '@techor/log'
import extend from '@techor/extend'
Expand All @@ -12,7 +12,7 @@ import chokidar from 'chokidar'
import { EventEmitter } from 'node:events'
import cssEscape from 'css-shared/utils/css-escape'
import { explorePathsSync, explorePathSync } from '@techor/glob'
import path from 'path'
import path, { resolve } from 'path'

export default class CSSExtractor extends EventEmitter {
latentClasses = new Set<string>()
Expand Down Expand Up @@ -42,6 +42,7 @@ export default class CSSExtractor extends EventEmitter {
log.tree(this.options)
log``
}

this.css = new MasterCSS(
typeof this.options.config === 'object'
? this.options.config
Expand Down Expand Up @@ -342,8 +343,20 @@ export default class CSSExtractor extends EventEmitter {
* computed from string `options.config`
*/
get configPath(): string | undefined {
if (typeof this.options.config === 'string' || Array.isArray(this.options.config)) {
return explorePathSync(this.options.config, { cwd: this.cwd })
if (typeof this.options.config === 'string') {
// try to find the config file with the given name and options.extensions
let foundConfigPath: string | undefined
let foundBasename: string | undefined
for (const eachExtension of ['js', 'mjs', 'ts', 'cjs', 'cts', 'mts']) {
const eachBasename = this.options.config + '.' + eachExtension
const eachPath = resolve(this.cwd || '', eachBasename)
if (existsSync(eachPath)) {
foundConfigPath = eachPath
foundBasename = eachBasename
break
}
}
return foundBasename
}
}

Expand All @@ -361,8 +374,20 @@ export default class CSSExtractor extends EventEmitter {
* computed from string `customOptions`
*/
get optionsPath(): string | undefined {
if (typeof this.customOptions === 'string' || Array.isArray(this.customOptions)) {
return explorePathSync(this.customOptions, { cwd: this.cwd })
if (typeof this.customOptions === 'string') {
// try to find the config file with the given name and options.extensions
let foundConfigPath: string | undefined
let foundBasename: string | undefined
for (const eachExtension of ['js', 'mjs', 'ts', 'cjs', 'cts', 'mts']) {
const eachBasename = this.customOptions + '.' + eachExtension
const eachPath = resolve(this.cwd || '', eachBasename)
if (existsSync(eachPath)) {
foundConfigPath = eachPath
foundBasename = eachBasename
break
}
}
return foundBasename
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/extractor/src/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const options: Options = {

export interface Options {
verbose?: number
config?: Pattern | Pattern[] | Config,
config?: string | Config,
output?: string,
path?: string,
module?: string,
Expand Down
2 changes: 1 addition & 1 deletion packages/language-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "module",
"scripts": {
"build": "techor build \"src/**/*.ts\"",
"dev": "techor dev",
"dev": "pnpm build --watch",
"type-check": "tsc --noEmit",
"lint": "eslint src",
"test": "jest"
Expand Down
2 changes: 1 addition & 1 deletion packages/language-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "module",
"scripts": {
"build": "techor build \"src/**/*.ts\"",
"dev": "techor dev",
"dev": "pnpm build --watch",
"type-check": "tsc --noEmit",
"lint": "eslint src"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/language-service/src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ export const settings = {
suggestions: true,
inspect: true,
previewColors: true,
config: 'master.css.{ts,js,mjs,cjs}'
config: 'master.css'
}
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@master/css.react",
"scripts": {
"build": "techor build \"src/**/*.tsx\"",
"dev": "techor dev",
"dev": "pnpm build --watch",
"type-check": "tsc --noEmit",
"lint": "eslint src",
"e2e": "playwright test -c e2e/playwright-ct.config.ts"
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "module",
"scripts": {
"build": "techor build",
"dev": "techor dev",
"dev": "pnpm build --watch",
"e2e": "playwright test",
"type-check": "tsc --noEmit",
"lint": "eslint src"
Expand Down
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@master/css-server",
"scripts": {
"build": "techor build \"src/**/*.ts\"",
"dev": "techor dev",
"dev": "pnpm build --watch",
"lint": "eslint ./src",
"type-check": "tsc --noEmit",
"test": "jest"
Expand Down
2 changes: 1 addition & 1 deletion packages/theme-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "theme-service",
"scripts": {
"build": "techor build",
"dev": "techor dev",
"dev": "pnpm build --watch",
"test": "jest",
"type-check": "tsc --noEmit",
"lint": "eslint src"
Expand Down
2 changes: 1 addition & 1 deletion packages/validator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@master/css-validator",
"scripts": {
"build": "techor build \"src/**/*.ts\"",
"dev": "techor dev",
"dev": "pnpm build --watch",
"lint": "eslint ./src",
"type-check": "tsc --noEmit",
"test": "jest --forceExit --detectOpenHandles"
Expand Down
4 changes: 2 additions & 2 deletions packages/vscode-language-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "master-css-vscode-language-service",
"scripts": {
"build": "techor build",
"dev": "techor dev",
"dev": "pnpm build --watch",
"type-check": "tsc --noEmit",
"lint": "eslint src",
"deploy": "mv ../../package.json ../../_package.json && npm i vsce -D && vsce publish && mv ../../_package.json ../../package.json"
Expand Down Expand Up @@ -177,7 +177,7 @@
},
"masterCSS.config": {
"type": "string",
"default": "master.css.{ts,js,mjs,cjs}"
"default": "master.css"
}
}
}
Expand Down

0 comments on commit 49d440d

Please sign in to comment.