Max
Max

Reputation: 504

Webpack - Import Less from TypeScript fails (css-loader)

I'm trying to build a test project with TypeScript via Webpack. Have just index.ts file and base.less (or base.css) file imported in index.ts and it fails with errors on css-loader. Without imported LESS (CSS) file in a .ts file all working good.

I have got another big project with JS only (no TypeScript) and it working good with the same webpack.config file (babel instead of ts loader).

[email protected]

All needed loaders are installed.

webpack.config.js and Bitbucket link to the test project

ERROR in ./~/css-loader/lib/css-base.js Module build failed: Error: Final loader didn't return a Buffer or String

enter image description here

enter image description here

Upvotes: 1

Views: 2265

Answers (1)

GProst
GProst

Reputation: 10227

You have a wrong RegExp rule for TypeScript loader in your webpack.config.js. You need this:

`test: /(.ts|.tsx)$/`

but you have this:

`test: /(.ts|.tsx)?/`

Which says: load as TypeScript file no matter what.

Upvotes: 1

Related Questions