-
Notifications
You must be signed in to change notification settings - Fork 15
Why custom scripts and not webpack for building styles? #12
Comments
That's a good point. I agree the existing setup should be improved, while keeping the overall idea of compiling CSS. One idea which came to my mind is using the following tools:
I would be glad to accept a PR in case someone is willing to help with that setup. |
We have a project that we have been building for some time now. I used your other package https://github.com/web-padawan/lit-components and have customized this for our current needs. The project now uses scss with I think the current process is similar what lit-css-loader allows to do but we are importing scss directly, the webpack converts it to css on the fly and the raw-loader allows importing css to lit component. Complete webpack rules
I can talk about my setup more in detail if interested/needed. I also created a sample setup just after giving some edits to your lit-components package. https://github.com/chanar/lit-scss-vaadin |
Thanks for sharing, I will evaluate the options. I would still prefer not to import |
lit-css-loader for Storybook and visual tests.. What is your idea for running styles in development without the need to generate build/dist? |
By this did you mean that when building for production, you would generate .css and have components importing .css instead of .scss. Which would mean using scss compilation with whatever tool (although needs to be certainly rollup, webpack etc) in development mode and only when building for production, -style.js files would be generated similar to your scripts folder functionality.
|
The generated CSS is always wrapped into |
Based on #15 we learned a few things
I understand one of Aybolit goals is "tool-agnostic", which makes sense, but I'm not very confident in estimating what's the next logical step is here. Can @web-padawan your thoughts, please? |
Yes, that's the current state of things. In the Aybolit setup, each package is a separate library. I agree this might not be optimal for more common case where each package is a component.
I do understand that, and the current setup was meant to deliver an MVP. As I mentioned above, I will evaluate the options and try using Unfortunately, I haven't had any time to work on this project for more than 2 weeks due to personal reasons. Hope to get back on track this week and continue on this subject, as well as #11 |
Is HMR possible with anything other than Webpack? It'd be useful to be able to hot-reload at least style changes in the browser, without needing full page reload. https://medium.com/webpack/webpack-and-rollup-the-same-but-different-a41ad427058c and rollup/rollup#50 seem to point to "no". |
AFAIK, using HMR is unlikely to work properly with web components because of duplicate Custom Element definitions. So I usually have to restart Storybook after doing a bunch of changes. |
@chanar @web-padawan perhaps #18 also resolves this issue now. As HMR is unlikely to work w/ custom elements, I see no specific reason to aim for further root level Webpack integration. Do you? |
We still need to turn the whole pack into x.bundle.js with minifications and so on. Webpack has perfect toolset for this. Also, what browsers we need to consider? So probably @web-padawan has had in mind to configure build script. But it usually is a thing to do depending on individual build needs. |
I think our bundling should happen at theme (already Webpacking via Laravel Mix) and app level (whatever your conversionxl/cxl-app repo does, or wants to do), but bundling is probably not needed in conversionxl/aybolit components monorepo. OTOH it may make sense to have known bundles, available directly from components monorepo. I wonder what @web-padawan thinks for this scenario. Maybe we talk this through in https://gitter.im/aybolitjs/community |
Regarding building minified output, there is a pika-plugin-minify which I have tried, but so far it looks like that plugin only covers I'm not inclined to use webpack for preparing Once webpack 5 with first-class ES modules support (as a compile target) is out, we can probably reconsider using it but right now it doesn't seem a proper choice. Of course in your projects you can use webpack, Parcel or anything (and Rollup, too). |
Closing issue as building styles now works properly |
Currently the npm run watch takes at least 1 second with minimal setup and only on package. So my questions is why custom scripts runner?
The text was updated successfully, but these errors were encountered: