Ratbek
Ratbek

Reputation: 163

An error occurs when importing css file in webpack

I use webpack. I installed style-loader module by command

npm install --save-dev style-loader

I import css-file like-this:

require('style!css!../css/style.css');

But when I run webpack by command

webpack -w --devtool source-map js/profile.js dist/bundle.js

occurs following error:

ERROR in ./js/profile.js Module not found: Error: Can't resolve 'style' in '/home/default-user/WebstormProjects/practice/webpack/js' BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders.You need to specify 'style-loader' instead of 'style',

Upvotes: 0

Views: 839

Answers (2)

Siya Mzam
Siya Mzam

Reputation: 4705

As the error says, Babel does not allow loader specification without the suffix -loader. So go on and replace style and css with style-loader and css-loader respectively.

Upvotes: 1

Ratbek
Ratbek

Reputation: 163

I found an answer. I have just added word "-loader" in importing ccs-file like this:

require('style-loader!css-loader!../css/style.css');

Upvotes: 0

Related Questions