highfive_
highfive_

Reputation: 77

Compile css files using only Typescript

I have a monorepo project which one project (main) depends on the other (components). So when I start the whole monorepo the main project uses a webpack.dev and the components project just use simple typescript compiler. Like this:

(main): yarn start: webpack-dev-server ...

(components): yarn start: tsc -b

I have no problem when it comes to only TS code, but when it comes to non-ts files (css) I get a webpack module missing error.

I've already put both css-loader and style-loader into my webpack config from my main project but it didn't seem to solve the problem, it looks like typescript is not compiling the css file correctly

in my component project I have some like this:

import "./index.css"

export const Button = () => {
...
}

and then I get this error from my main project

Module not found: Error: Can't resolve './index.css' in '{...}/frontend/design-components/build'

my webpack in my main project:

 module: {
    rules: [
      ...,
      {
        test: /\.css$/i,
        use: ['style-loader', 'css-loader'],
      },
    ],

but I think the main problem is the way the components project is handling the build (i'm building only with typescript, no rollup nor webpack in this project)

Upvotes: 0

Views: 1253

Answers (1)

highfive_
highfive_

Reputation: 77

just ended up creating a webpack for my component project as well

Upvotes: 1

Related Questions