@pwrs/lit-css 2.0.0 → 3.0.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 +2549 -451
- package/lit-css.d.ts +4 -4
- package/lit-css.js +17 -18
- package/package.json +2 -3
package/lit-css.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Options as CssnanoOptions } from 'cssnano';
|
|
2
2
|
export interface Meta {
|
|
3
3
|
/**
|
|
4
4
|
* Path to the source file being transformed
|
|
@@ -27,10 +27,10 @@ export interface Options {
|
|
|
27
27
|
*/
|
|
28
28
|
tag?: string;
|
|
29
29
|
/**
|
|
30
|
-
* Whether to
|
|
30
|
+
* Whether to minify the CSS using cssnano. can also be an object of css nano options.
|
|
31
31
|
* @default false
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
cssnano?: boolean | CssnanoOptions;
|
|
34
34
|
/**
|
|
35
35
|
* Transform sources using tools like sass or postcss
|
|
36
36
|
* @param source Source file contents e.g. scss or postcss sources
|
|
@@ -39,4 +39,4 @@ export interface Options {
|
|
|
39
39
|
*/
|
|
40
40
|
transform?(source: string, meta: Meta): string | Promise<string>;
|
|
41
41
|
}
|
|
42
|
-
export declare function transform({ css: source, filePath, specifier, tag,
|
|
42
|
+
export declare function transform({ css: source, filePath, specifier, tag, cssnano, transform, }: Options): Promise<string>;
|
package/lit-css.js
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import cssnano from 'cssnano';
|
|
2
|
+
function stringToTemplateLiteral(x = '') {
|
|
3
|
+
x = `${x}`;
|
|
4
|
+
const escaped = x.replace(/\\|`|\$(?={)|(?<=<)\//g, y => `\\${y}`);
|
|
5
|
+
return `\`${escaped}\``;
|
|
6
|
+
}
|
|
7
|
+
async function cssnanoify(css, options) {
|
|
8
|
+
const cssnanoOptions = typeof options === 'object' ? options : undefined;
|
|
9
|
+
const result = await cssnano(cssnanoOptions).process(css);
|
|
10
|
+
return result.css;
|
|
11
|
+
}
|
|
12
|
+
export async function transform({ css: source, filePath, specifier = 'lit', tag = 'css', cssnano = false, transform = x => x, }) {
|
|
13
|
+
const css = await transform(source, { filePath });
|
|
14
|
+
const cssContent = cssnano ? await cssnanoify(css, cssnano)
|
|
15
|
+
: css;
|
|
16
|
+
return `import {${tag}} from '${specifier}';
|
|
15
17
|
export const styles = ${tag}${stringToTemplateLiteral(cssContent)};
|
|
16
18
|
export default styles;
|
|
17
19
|
`;
|
|
18
20
|
}
|
|
19
|
-
|
|
20
|
-
transform
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=lit-css.js.map
|
|
21
|
+
//# sourceMappingURL=lit-css.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pwrs/lit-css",
|
|
3
3
|
"description": "Import CSS files as css tagged-template literals",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lit-css.js",
|
|
7
7
|
"types": "lit-css.d.ts",
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
"lit-css.d.ts"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"
|
|
34
|
-
"uglifycss": "^0.0.29"
|
|
33
|
+
"cssnano": "^6.1.2"
|
|
35
34
|
}
|
|
36
35
|
}
|