@plumeria/compiler 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.ts +5 -25
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -8,24 +8,6 @@ import { buildGlobal } from '@plumeria/core/dist/method/global-build-helper.js';
|
|
|
8
8
|
import postcss from 'postcss';
|
|
9
9
|
import combineSelectors from 'postcss-combine-duplicated-selectors';
|
|
10
10
|
|
|
11
|
-
function findUp(filename: string, startDir = __dirname) {
|
|
12
|
-
let dir = path.resolve(startDir);
|
|
13
|
-
|
|
14
|
-
while (true) {
|
|
15
|
-
const filePath = path.join(dir, filename);
|
|
16
|
-
if (fs.existsSync(filePath)) {
|
|
17
|
-
return filePath;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const parentDir = path.dirname(dir);
|
|
21
|
-
if (dir === parentDir) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
dir = parentDir;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
11
|
function isCSS(filePath: string): boolean {
|
|
30
12
|
const content = fs.readFileSync(filePath, 'utf8');
|
|
31
13
|
const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);
|
|
@@ -42,13 +24,11 @@ function isCSS(filePath: string): boolean {
|
|
|
42
24
|
return checker(sourceFile);
|
|
43
25
|
}
|
|
44
26
|
|
|
45
|
-
async function getAppRoot() {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
throw new Error('Project root directory not found');
|
|
51
|
-
}
|
|
27
|
+
async function getAppRoot(): Promise<string> {
|
|
28
|
+
const threeLevelsUp = path.join(process.cwd(), '../../../../..');
|
|
29
|
+
return fs.existsSync(path.join(threeLevelsUp, 'node_modules/.pnpm'))
|
|
30
|
+
? path.join(process.cwd(), '../../../../../')
|
|
31
|
+
: path.join(process.cwd(), '../../');
|
|
52
32
|
}
|
|
53
33
|
|
|
54
34
|
async function optimizeCSS() {
|