0

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',

olore
  • 4,687
  • 3
  • 28
  • 40
Ratbek
  • 143
  • 1
  • 7
  • BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders.You need to specify 'style-loader' instead of 'style' Looks like you have to use that approach https://stackoverflow.com/questions/42196583 – Mikhail Aksenov Nov 29 '17 at 12:25
  • Possible duplicate of [webpack Can't resolve 'style'](https://stackoverflow.com/questions/42196583/webpack-cant-resolve-style) – Siya Mzam Nov 30 '17 at 03:26

2 Answers2

1

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.

Siya Mzam
  • 4,655
  • 1
  • 26
  • 44
0

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

require('style-loader!css-loader!../css/style.css');
Ratbek
  • 143
  • 1
  • 7