@pwrs/lit-css 2.1.0 → 3.0.1

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.
Files changed (4) hide show
  1. package/lit-css.cjs +2350 -87441
  2. package/lit-css.d.ts +1 -8
  3. package/lit-css.js +15 -27
  4. package/package.json +2 -4
package/lit-css.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { UglifyCSSOptions } from 'uglifycss';
2
1
  import { Options as CssnanoOptions } from 'cssnano';
3
2
  export interface Meta {
4
3
  /**
@@ -27,12 +26,6 @@ export interface Options {
27
26
  * @default 'css'
28
27
  */
29
28
  tag?: string;
30
- /**
31
- * Whether to uglify the CSS. Can also be an object of uglifycss options
32
- * @default false
33
- * @deprecated: use `minify`
34
- */
35
- uglify?: boolean | UglifyCSSOptions;
36
29
  /**
37
30
  * Whether to minify the CSS using cssnano. can also be an object of css nano options.
38
31
  * @default false
@@ -46,4 +39,4 @@ export interface Options {
46
39
  */
47
40
  transform?(source: string, meta: Meta): string | Promise<string>;
48
41
  }
49
- export declare function transform({ css: source, filePath, specifier, tag, uglify, cssnano, transform, }: Options): Promise<string>;
42
+ export declare function transform({ css: source, filePath, specifier, tag, cssnano, transform, }: Options): Promise<string>;
package/lit-css.js CHANGED
@@ -1,33 +1,21 @@
1
- import stringToTemplateLiteral from "string-to-template-literal";
2
- import { processString } from "uglifycss";
3
- import cssnano from "cssnano";
4
- async function cssnanoify(css, options) {
5
- const cssnanoOptions = typeof options === "object" ? options : void 0;
6
- const result = await cssnano(cssnanoOptions).process(css);
7
- return result.css;
1
+ import cssnano from 'cssnano';
2
+ function stringToTemplateLiteral(x = '') {
3
+ x = `${x}`;
4
+ const escaped = x.replace(/\\|`|\$(?={)|(?<=<)\//g, y => `\\${y}`);
5
+ return `\`${escaped}\``;
8
6
  }
9
- async function uglifycssify(css, options) {
10
- const uglifyOptions = typeof options === "object" ? options : void 0;
11
- const result = processString(css, uglifyOptions);
12
- return result;
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;
13
11
  }
14
- async function transform({
15
- css: source,
16
- filePath,
17
- specifier = "lit",
18
- tag = "css",
19
- uglify = false,
20
- cssnano: cssnano2 = false,
21
- transform: transform2 = (x) => x
22
- }) {
23
- const css = await transform2(source, { filePath });
24
- const cssContent = cssnano2 ? await cssnanoify(css, cssnano2) : uglify ? await uglifycssify(css, uglify) : css;
25
- return `import {${tag}} from '${specifier}';
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}';
26
17
  export const styles = ${tag}${stringToTemplateLiteral(cssContent)};
27
18
  export default styles;
28
19
  `;
29
20
  }
30
- export {
31
- transform
32
- };
33
- //# 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": "2.1.0",
4
+ "version": "3.0.1",
5
5
  "type": "module",
6
6
  "main": "lit-css.js",
7
7
  "types": "lit-css.d.ts",
@@ -30,8 +30,6 @@
30
30
  "lit-css.d.ts"
31
31
  ],
32
32
  "dependencies": {
33
- "cssnano": "^6.0.1",
34
- "string-to-template-literal": "^2.0.0",
35
- "uglifycss": "^0.0.29"
33
+ "cssnano": "^7.0.6"
36
34
  }
37
35
  }