@pwrs/lit-css 1.1.0 → 1.2.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/lit-css.cjs +2 -1
- package/lit-css.d.ts +8 -3
- package/lit-css.js +2 -1
- package/package.json +1 -1
package/lit-css.cjs
CHANGED
|
@@ -546,12 +546,13 @@ var import_uglifycss = __toModule(require_uglifycss());
|
|
|
546
546
|
function transform(_0) {
|
|
547
547
|
return __async(this, arguments, function* ({
|
|
548
548
|
css: source,
|
|
549
|
+
filePath,
|
|
549
550
|
specifier = "lit",
|
|
550
551
|
tag = "css",
|
|
551
552
|
uglify = false,
|
|
552
553
|
transform: transform2 = (x) => x
|
|
553
554
|
}) {
|
|
554
|
-
const css = yield transform2(source);
|
|
555
|
+
const css = yield transform2(source, { filePath });
|
|
555
556
|
const uglifyOptions = typeof uglify === "object" ? uglify : void 0;
|
|
556
557
|
const cssContent = !uglify ? css : (0, import_uglifycss.processString)(css, uglifyOptions);
|
|
557
558
|
return `import {${tag}} from '${specifier}';
|
package/lit-css.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { UglifyCSSOptions } from 'uglifycss';
|
|
|
2
2
|
export interface Options {
|
|
3
3
|
/** CSS to transform */
|
|
4
4
|
css: string;
|
|
5
|
+
/** Absolute (i.e. resolved) path to the css file */
|
|
6
|
+
filePath?: string;
|
|
5
7
|
/**
|
|
6
8
|
* Module specifier that exports the template tag.
|
|
7
9
|
* @default 'lit'
|
|
@@ -19,9 +21,12 @@ export interface Options {
|
|
|
19
21
|
uglify?: boolean | UglifyCSSOptions;
|
|
20
22
|
/**
|
|
21
23
|
* Transform sources using tools like sass or postcss
|
|
22
|
-
* @param source Source file e.g. scss or postcss sources
|
|
24
|
+
* @param source Source file contents e.g. scss or postcss sources
|
|
25
|
+
* @param meta Source file absolute (i.e. resolved) path
|
|
23
26
|
* @return Transformed, standard CSS
|
|
24
27
|
*/
|
|
25
|
-
transform?(source: string
|
|
28
|
+
transform?(source: string, meta?: {
|
|
29
|
+
filePath: string;
|
|
30
|
+
}): string | Promise<string>;
|
|
26
31
|
}
|
|
27
|
-
export declare function transform({ css: source, specifier, tag, uglify, transform, }: Options): Promise<string>;
|
|
32
|
+
export declare function transform({ css: source, filePath, specifier, tag, uglify, transform, }: Options): Promise<string>;
|
package/lit-css.js
CHANGED
|
@@ -2,12 +2,13 @@ import stringToTemplateLiteral from "string-to-template-literal";
|
|
|
2
2
|
import { processString } from "uglifycss";
|
|
3
3
|
async function transform({
|
|
4
4
|
css: source,
|
|
5
|
+
filePath,
|
|
5
6
|
specifier = "lit",
|
|
6
7
|
tag = "css",
|
|
7
8
|
uglify = false,
|
|
8
9
|
transform: transform2 = (x) => x
|
|
9
10
|
}) {
|
|
10
|
-
const css = await transform2(source);
|
|
11
|
+
const css = await transform2(source, { filePath });
|
|
11
12
|
const uglifyOptions = typeof uglify === "object" ? uglify : void 0;
|
|
12
13
|
const cssContent = !uglify ? css : processString(css, uglifyOptions);
|
|
13
14
|
return `import {${tag}} from '${specifier}';
|