petervmeijgaard/vue-2-boilerplate

Error trying to require SASS in bootstrap js

jimsheen opened this issue · 8 comments

I am trying to require SASS instead of stylus in bootstrap.js by replacing

require('./assets/stylus/app.styl');

with

require('./assets/scss/app.scss');

but I get this error

This relative module was not found:
* ./assets/scss/app.scss in ./src/bootstrap.js

and in browser

ERROR in ./src/bootstrap.js
Module not found: Error: Can't resolve 'style' in '/Users/james/Documents/Projects/vue-test2'
BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders.
                 You need to specify 'style-loader' instead of 'style',
                 see https://webpack.js.org/guides/migrating/#automatic-loader-module-name-extension-removed
 @ ./src/bootstrap.js 78:0-34
 @ ./src/main.js
 @ multi ./build/dev-client ./src/main.js

Is this possible a misconfiguration in the utils.js file to do with styleLoaders function or the generateLoaders() function?

I have all necessary dependancies installed:
sass-loader
style-loader
css-loader
node-sass

You need to run npm i --save-dev sass-loader node-sass or yarn add -D sass-loader node-sass in order to use SASS instead of Stylus :)

@petervmeijgaard Thanks for your quick reply, I have already tried that and I am positive these loaders are installed but I am still getting the same issue

Could you wrap your code in three backticks? (`)
It'll make it a bit better to look at :)

That's odd, it's referencing to ./assets/scss/main.sass instead of ./assets/sass/app.scss.
Are you sure the path to the stylesheet is correct?

Yes I'm positive the path is correct, I was just trying different combinations when I copy pasted it. Apologies

I've tried to reproduce your problem, but it's working correctly at my end.
I ran yarn add -D sass-loader node-sass, changed src/assets/stylus/app.styl to src/assets/stylus/app.scss, required the correct file in my bootstrap.js-file and everything works like a charm. I've also tried by using app.sass instead of app.scss.

Last but not least, I've removed my node_modules and ran npm install. This also works like a charm...

Perhaps you can try to remove node_modules and run npm install or yarn again.
It could be OS related. What OS are you using?

@jimsheen Could you please give me more information about the issue you are encountering?

I'm closing this issue due to inactivity and lack of information.