bennypowers / lit-css Goto Github PK
View Code? Open in Web Editor NEWBuild Plugins for CSS tagged-template-literals
License: MIT License
Build Plugins for CSS tagged-template-literals
License: MIT License
UglifyCSS replacing 0px
s to 0
without any configuration options. And that causes issues with using 0px
in CSS variables, like defined here: https://www.oddbird.net/2022/08/04/zero-units/
When I check UglifyCSS repository I see that it's not maintained for a long time. Can we consider replacing it with a more modern and configurable option like clean-css?
Hi, thank you so much for this library.
I am using this because I need auto-prefixing on my css, and I'm chaining postcss-loader before this. It's not working right now, and I don't really understand why.
Could we maybe document a known-good webpack config to do this?
Given the following rollup config:
// @ts-check
import resolve from "@rollup/plugin-node-resolve"
import typescript from "@rollup/plugin-typescript"
import litCss from "rollup-plugin-lit-css"
export default {
input: "src/index.ts",
plugins: [
// Resolve bare module specifiers to relative paths
resolve({ extensions: [".mjs", ".js", ".json", ".ts"] }),
// transform css files into Lit-compatible format
litCss({ include: ["src/**/*.css"] }),
// transform typescript
typescript({
include: ["src/index.ts", "src/**/*.ts", "globals.d.ts"],
}),
],
output: {
dir: "lib",
sourcemap: true,
},
}
TS complains with the following error:
Argument of type '{ include: string[]; }' is not assignable to parameter of type 'LitCSSOptions'.
Property 'css' is missing in type '{ include: string[]; }' but required in type 'LitCSSOptions'
Users should be able to opt-in to polyfilling css modules / import assertions, rather than getting the css-tagged-literal version
A later breaking version would switch it to opt-out (i.e., users would then have to opt-in to what is now current behaviour)
Hi. I got very excited when I learned about this plugin on Twitter, it's exactly what we need on project using lit elements.
However I'm having problems configuring this in an Angular (12+) app.
Could you maybe give some guidance or advice on how to get up and running using Angular?
I'm currently trying using @angular-builders/custom-webpack, but no luck yet.
Thanks a lot and thanks for you work on this.
The peer dependency on esbuild v0.12.14 is restricting usage of this plugin with latest esbuild.
Any chance we could get an update?
Compiles only at startup, watch mode does not compile just-in-time, is just-in-time compilation not supported?
Project configuration:
import litcss from 'rollup-plugin-lit-css';
import postcssConfig from 'postcss-load-config';
const config = await postcssConfig();
plugins: [
litcss({ transform: (css, { filePath }) => postcss(config.plugins).process(css, { from: filePath }).css }),
]
postcss.config.js
import tailwindcss from 'tailwindcss';
export default {
plugins: [tailwindcss],
};
Hi. I'm having issues using this with a create-react-app
.
I'm using react-app-rewired
and customize-cra
to override the configs.
The config looks like this:
const { override, addWebpackModuleRule } = require('customize-cra');
module.exports = override(
addWebpackModuleRule({
test: /\.ccss$/,
loader: 'lit-css-loader'
})
);
But I get this error when trying to run the app:
Failed to compile.
./src/heimdall/components/text/styles.ccss
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: [path-to-my-app]/node_modules/lit-css-loader/lit-css-loader.js
require() of ES modules is not supported.
require() of [path-to-my-app]/node_modules/lit-css-loader/lit-css-loader.js from [path-to-my-app]/node_modules/loader-runner/lib/loadLoader.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename lit-css-loader.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from [path-to-my-app]/node_modules/lit-css-loader/package.json.
Maybe you can help?
Thanks a lot.
The package.json references two cjs
files (with different file names?):
The npm package of version 3.0.0 does not include any of these.
I don't know if it's a ts-patch bug or typescript-transform-lit-css.
Typescript 5.4 :
imports are transformed with a lit css tag.
Typescript 5.5 :
nothing change,
import styles from './internal/checkbox-styles.css';
Would it be possible to update the package.json
to allow esbuild versions > 0.20.x?
Currently I have to use an overrides
like this:
"overrides": {
"esbuild-plugin-lit-css": {
"esbuild": "^0.23.0"
}
}
Thanks for this very useful library!
My project use vite so that I choose rollup-plugin-lit-css。
this is my vite.config.js
import { defineConfig } from "vite";
import litcss from "rollup-plugin-lit-css";
export default defineConfig({
plugins: [
litcss({
include: "/src/components/**/*.css",
uglify: true,
}),
],
build: {
lib: {
entry: "src/my-element.js",
formats: ["es"],
},
rollupOptions: {
external: /^lit/,
},
},
});
and this is my element code
import { LitElement, css, html } from "lit";
import style from "./index.css";
export class HelloWorld extends LitElement {
constructor() {
super();
}
render() {
return html` <div>Hello World</div> `;
}
static styles = [style];
}
window.customElements.define("hello-world", HelloWorld);
but vite echo Default and named imports from CSS files are deprecated. Use the ?inline query instead. For example: import style from "./index.css?inline
so the import code transform
import style from "./index.css?inline";
but lit echo Failed to set the 'adoptedStyleSheets' property on 'ShadowRoot': Failed to convert value to 'CSSStyleSheet'.
so can you provide a project template for vite?
tks
esbuild 0.18 has been released (see https://github.com/evanw/esbuild/blob/main/CHANGELOG.md) but npm
refuses to update my dependencies:
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @cedx/[email protected]
npm WARN Found: [email protected]
npm WARN node_modules/esbuild
npm WARN dev esbuild@"^0.18.0" from the root project
npm WARN 1 more (esbuild-plugin-minify-html-literals)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer esbuild@"^0.16.17 || ^0.17.16" from [email protected]
npm WARN node_modules/esbuild-plugin-minify-html-literals
npm WARN dev esbuild-plugin-minify-html-literals@"^1.0.4" from the root project
Can you check/fix this? Thank you in advance.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.