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
29 changes: 11 additions & 18 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// @ts-check
const { resolve } = require('node:path')
let { resolve } = require('node:path')

const config = require('lilconfig')
let { lilconfig } = require('lilconfig')

const loadOptions = require('./options.js')
const loadPlugins = require('./plugins.js')
const req = require('./req.js')
let loadOptions = require('./options.js')
let loadPlugins = require('./plugins.js')
let req = require('./req.js')

const interopRequireDefault = obj =>
let interopRequireDefault = obj =>
obj && obj.__esModule ? obj : { default: obj }

/**
Expand All @@ -28,9 +28,7 @@ async function processResult(ctx, result) {
projectConfig = { ...projectConfig, ...ctx }
}

if (!projectConfig.plugins) {
projectConfig.plugins = []
}
if (!projectConfig.plugins) projectConfig.plugins = []

let res = {
file,
Expand Down Expand Up @@ -61,9 +59,7 @@ function createContext(ctx) {
...ctx
}

if (!ctx.env) {
process.env.NODE_ENV = 'development'
}
if (!ctx.env) process.env.NODE_ENV = 'development'

return ctx
}
Expand All @@ -89,7 +85,7 @@ async function yamlLoader(_, content) {
}

/** @return {import('lilconfig').Options} */
const withLoaders = (options = {}) => {
let withLoaders = (options = {}) => {
let moduleName = 'postcss'

return {
Expand Down Expand Up @@ -150,13 +146,10 @@ function rc(ctx, path, options) {
*/
path = path ? resolve(path) : process.cwd()

return config
.lilconfig('postcss', withLoaders(options))
return lilconfig('postcss', withLoaders(options))
.search(path)
.then(result => {
if (!result) {
throw new Error(`No PostCSS Config found in: ${path}`)
}
if (!result) throw new Error(`No PostCSS Config found in: ${path}`)
return processResult(ctx, result)
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/options.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
const req = require('./req.js')
let req = require('./req.js')

/**
* Load Options
Expand Down
6 changes: 2 additions & 4 deletions src/plugins.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
const req = require('./req.js')
let req = require('./req.js')

/**
* Plugin Loader
Expand Down Expand Up @@ -59,9 +59,7 @@ async function plugins(config, file) {

if (list.length && list.length > 0) {
list.forEach((plugin, i) => {
if (plugin.default) {
plugin = plugin.default
}
if (plugin.default) plugin = plugin.default

if (plugin.postcss === true) {
plugin = plugin()
Expand Down
6 changes: 3 additions & 3 deletions src/req.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// @ts-check
const { createRequire } = require('node:module')
const { pathToFileURL } = require('node:url')
let { createRequire } = require('node:module')
let { pathToFileURL } = require('node:url')

const TS_EXT_RE = /\.[mc]?ts$/
let TS_EXT_RE = /\.[mc]?ts$/

let tsx

Expand Down