How to setup sass modules in packages/ui? #692
Replies: 5 comments 4 replies
-
This is not related to monorepos, but I will attempt to help you anyways. I use packages in my apps without a build step. I installed Vite and sass in my apps as dev dependencies. I used Vite because it supports Sass and CSS modules out of the box. Now any packages I use in my apps know how to process imports of If you use a build step (compile package source code so that changes can be visible inside apps) for your |
Beta Was this translation helpful? Give feedback.
-
I am also curious about this. |
Beta Was this translation helpful? Give feedback.
-
I'm also trying to achieve the same thing, trying to use CSS modules in |
Beta Was this translation helpful? Give feedback.
-
I ended up ditching I first installed the following packages:
Inside my ui-core "scripts": {
"build": "rollup -c --bundleConfigAsCjs",
"dev": "rollup -c -w --bundleConfigAsCjs",
} Inside my ui-core import peerDepsExternal from "rollup-plugin-peer-deps-external";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "rollup-plugin-typescript2";
import postcss from "rollup-plugin-postcss";
const packageJson = require("./package.json");
export default {
input: "src/index.ts",
output: [
{
file: packageJson.main,
format: "cjs",
sourcemap: true,
},
{
file: packageJson.module,
format: "esm",
sourcemap: true,
},
],
plugins: [
peerDepsExternal(),
resolve(),
commonjs(),
typescript({ useTsconfigDeclarationDir: true }),
postcss(),
],
external: ['react', 'react-dom'],
}; EDIT/ADDITION: Alternatively, it looks like you could also accomplish this with Vite with something like this, which is already bundling Storybook: Inside my ui-core "scripts": {
"dev": "npx vite",
"build": "npx vite build"
} Inside my ui-core import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
// https://vitejs.dev/config/
export default defineConfig((configEnv) => ({
plugins: [react()],
build: {
rollupOptions: {
// https://rollupjs.org/guide/en/#big-list-of-options
input: "src/index.ts",
output: [
{
format: "cjs",
entryFileNames: "index.js",
},
{
format: "esm",
entryFileNames: "index.mjs",
},
],
},
},
})); |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
I'm planning to use turborepo to manage the codebase of the two web apps that will be deployed in different domains. I'm using turborepo because i want to share the UI components/logic between the two web apps.
Beta Was this translation helpful? Give feedback.
All reactions