Our great sponsors
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
import { nodeResolve } from "@rollup/plugin-node-resolve"; import postcss from "rollup-plugin-postcss"; import copy from "rollup-plugin-copy"; export default [ { input: "src/js/combine.js", output: { file: "src/js/minified/index.bundle.js", sourcemap: false, } plugins: [ nodeResolve(), postcss({ extract: true, // no way to move output to another folder https://github.com/egoist/rollup-plugin-postcss/issues/250 minimize: true, }), copy({ targets: [ { src: "src/js/minified/index.bundle.css", dest: "src/styles/minified", rename: "fonts.bundle.css", }, ], verbose: true, hook: "writeBundle", }) ], } ];
Slinkity uses vite for bundling which is great, but it became a problem for me. I have a relatively old and large project with some custom configurations which came in the way of how vite does things, so migrating to vite resulted in a mess. The migration needs more time. So, I decided to take another approach which might be not so good.
Now, to extract css, I used the postcss rollup plugin and the rollup copy plugin to copy the generated css file to the desired directory. I had to use rollup-plugin-copy because of this issue.
I stumbled upon fontsource.org the other day and I found the idea of installing fonts from npm packages appealing.
At first, I used it in my personal site built with Astro. The process was incredibly simple. You just have to import fonts in your base layout file and that's it. You are ready to use it in your CSS!
Related posts
- Approaches to Styling React Components, Best Use Cases
- How to use ChatGPT to build macOS applications without any code experience
- Module Federation using ViteJS - Step into the Micro-frontend architecture
- Is there a solution for CSS modules that would allow to have TSX and CSS in the same file?
- Just add Storybook v7 into my React Boilerplate built with Next.js + TypeScript + Tailwind CSS + ESLint + Prettier + Jest + Cypress