Merge branch 'master' into diagnostics
commit
4fb1e980e4
|
@ -181,6 +181,7 @@
|
||||||
"pkg-up": "^3.1.0",
|
"pkg-up": "^3.1.0",
|
||||||
"postcss": "^7.0.27",
|
"postcss": "^7.0.27",
|
||||||
"postcss-selector-parser": "^6.0.2",
|
"postcss-selector-parser": "^6.0.2",
|
||||||
|
"resolve-from": "^5.0.0",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"semver": "^7.3.2",
|
"semver": "^7.3.2",
|
||||||
"stack-trace": "0.0.10",
|
"stack-trace": "0.0.10",
|
||||||
|
|
|
@ -2,12 +2,17 @@ import * as path from 'path'
|
||||||
import stackTrace from 'stack-trace'
|
import stackTrace from 'stack-trace'
|
||||||
import pkgUp from 'pkg-up'
|
import pkgUp from 'pkg-up'
|
||||||
import { isObject } from './isObject'
|
import { isObject } from './isObject'
|
||||||
|
import resolveFrom from 'resolve-from'
|
||||||
import importFrom from 'import-from'
|
import importFrom from 'import-from'
|
||||||
|
|
||||||
export async function getBuiltInPlugins({ cwd, resolvedConfig }) {
|
export async function getBuiltInPlugins({ cwd, resolvedConfig }) {
|
||||||
|
const tailwindBase = path.dirname(
|
||||||
|
resolveFrom(cwd, 'tailwindcss/package.json')
|
||||||
|
)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// TODO: add v0 support ("generators")
|
// TODO: add v0 support ("generators")
|
||||||
return importFrom(cwd, 'tailwindcss/lib/corePlugins.js').default({
|
return importFrom(tailwindBase, './lib/corePlugins.js').default({
|
||||||
corePlugins: resolvedConfig.corePlugins,
|
corePlugins: resolvedConfig.corePlugins,
|
||||||
})
|
})
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
|
|
|
@ -2,6 +2,7 @@ import extractClassNames from './extractClassNames'
|
||||||
import Hook from './hook'
|
import Hook from './hook'
|
||||||
import dlv from 'dlv'
|
import dlv from 'dlv'
|
||||||
import dset from 'dset'
|
import dset from 'dset'
|
||||||
|
import resolveFrom from 'resolve-from'
|
||||||
import importFrom from 'import-from'
|
import importFrom from 'import-from'
|
||||||
import chokidar from 'chokidar'
|
import chokidar from 'chokidar'
|
||||||
import semver from 'semver'
|
import semver from 'semver'
|
||||||
|
@ -55,13 +56,16 @@ export default async function getClassNames(
|
||||||
invariant(configPath.length === 1, 'No Tailwind CSS config found.')
|
invariant(configPath.length === 1, 'No Tailwind CSS config found.')
|
||||||
configPath = configPath[0]
|
configPath = configPath[0]
|
||||||
const configDir = path.dirname(configPath)
|
const configDir = path.dirname(configPath)
|
||||||
postcss = importFrom(configDir, 'postcss')
|
const tailwindBase = path.dirname(
|
||||||
|
resolveFrom(configDir, 'tailwindcss/package.json')
|
||||||
|
)
|
||||||
|
postcss = importFrom(tailwindBase, 'postcss')
|
||||||
tailwindcss = importFrom(configDir, 'tailwindcss')
|
tailwindcss = importFrom(configDir, 'tailwindcss')
|
||||||
version = importFrom(configDir, 'tailwindcss/package.json').version
|
version = importFrom(configDir, 'tailwindcss/package.json').version
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// this is not required
|
// this is not required
|
||||||
browserslistModule = importFrom(configDir, 'browserslist')
|
browserslistModule = importFrom(tailwindBase, 'browserslist')
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
|
|
||||||
const sepLocation = semver.gte(version, '0.99.0')
|
const sepLocation = semver.gte(version, '0.99.0')
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
|
import resolveFrom from 'resolve-from'
|
||||||
import importFrom from 'import-from'
|
import importFrom from 'import-from'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import decache from './decache'
|
import decache from './decache'
|
||||||
|
|
||||||
export default function resolveConfig({ cwd, config }) {
|
export default function resolveConfig({ cwd, config }) {
|
||||||
let resolve = x => x
|
const tailwindBase = path.dirname(
|
||||||
|
resolveFrom(cwd, 'tailwindcss/package.json')
|
||||||
|
)
|
||||||
|
let resolve = (x) => x
|
||||||
|
|
||||||
if (typeof config === 'string') {
|
if (typeof config === 'string') {
|
||||||
if (!cwd) {
|
if (!cwd) {
|
||||||
|
@ -14,18 +18,18 @@ export default function resolveConfig({ cwd, config }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
resolve = importFrom(cwd, 'tailwindcss/resolveConfig.js')
|
resolve = importFrom(tailwindBase, './resolveConfig.js')
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
try {
|
try {
|
||||||
const resolveConfig = importFrom(
|
const resolveConfig = importFrom(
|
||||||
cwd,
|
tailwindBase,
|
||||||
'tailwindcss/lib/util/resolveConfig.js'
|
'./lib/util/resolveConfig.js'
|
||||||
)
|
)
|
||||||
const defaultConfig = importFrom(
|
const defaultConfig = importFrom(
|
||||||
cwd,
|
tailwindBase,
|
||||||
'tailwindcss/stubs/defaultConfig.stub.js'
|
'./stubs/defaultConfig.stub.js'
|
||||||
)
|
)
|
||||||
resolve = config => resolveConfig([config, defaultConfig])
|
resolve = (config) => resolveConfig([config, defaultConfig])
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -188,7 +188,7 @@ export function findClassListsInHtmlRange(
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
classList: value,
|
classList: value.substr(beforeOffset, value.length + afterOffset),
|
||||||
range: {
|
range: {
|
||||||
start: {
|
start: {
|
||||||
line: (range?.start.line || 0) + start.line,
|
line: (range?.start.line || 0) + start.line,
|
||||||
|
|
Loading…
Reference in New Issue