auklet 0.0.14 → 0.0.15
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.
|
@@ -11,6 +11,7 @@ export declare class StyleProcessor {
|
|
|
11
11
|
appendStyleContent(target: Root, content: string, from: string): void;
|
|
12
12
|
readStyleFile(stylePath: string, seen?: Set<string>): string;
|
|
13
13
|
collectImportedStyleFiles(styleFiles: Array<string>): Set<string>;
|
|
14
|
+
collectStyleImportSpecifiers(styleFiles: Array<string>): Set<string>;
|
|
14
15
|
private parse;
|
|
15
16
|
private parseImportSpecifier;
|
|
16
17
|
}
|
|
@@ -78,6 +78,18 @@ export class StyleProcessor {
|
|
|
78
78
|
}
|
|
79
79
|
return imported;
|
|
80
80
|
}
|
|
81
|
+
collectStyleImportSpecifiers(styleFiles) {
|
|
82
|
+
const specifiers = new Set();
|
|
83
|
+
for (const styleFile of styleFiles) {
|
|
84
|
+
const css = fs.readFileSync(styleFile, 'utf8');
|
|
85
|
+
const root = this.parse(css, styleFile);
|
|
86
|
+
root.walkAtRules('import', (rule) => {
|
|
87
|
+
const specifier = this.parseImportSpecifier(rule.params);
|
|
88
|
+
if (specifier) specifiers.add(specifier);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return specifiers;
|
|
92
|
+
}
|
|
81
93
|
parse(code, from) {
|
|
82
94
|
// Keep parsing behind one method so future style languages can transform
|
|
83
95
|
// to CSS before PostCSS reads the final stylesheet.
|
|
@@ -21,8 +21,16 @@ export class ComponentStyleEntryWriter {
|
|
|
21
21
|
this.config.output.styleDir,
|
|
22
22
|
);
|
|
23
23
|
const target = path.join(styleDir, this.config.output.indexStyleFile);
|
|
24
|
+
const ownImports = this.styleProcessor.collectStyleImportSpecifiers(
|
|
25
|
+
entry.ownStyleFiles,
|
|
26
|
+
);
|
|
24
27
|
const sourceStyleSpecifiers = [
|
|
25
|
-
...this.getModuleStyleSpecifiers(
|
|
28
|
+
...this.getModuleStyleSpecifiers(
|
|
29
|
+
entry.moduleStyleImports.filter(
|
|
30
|
+
(specifier) => !ownImports.has(specifier),
|
|
31
|
+
),
|
|
32
|
+
styleDir,
|
|
33
|
+
),
|
|
26
34
|
...this.getOwnStyleSpecifiers(entry.ownStyleFiles, styleDir, outRoot),
|
|
27
35
|
];
|
|
28
36
|
const root = this.styleProcessor.createRoot();
|