M
M
MFT2020-07-13 19:54:27
JavaScript
MFT, 2020-07-13 19:54:27

Webpack: how to fix Module not found: Error: Can't resolve './src/base.scss'?

Hello! This is my first time trying to use sass. Setting up webpack:

const ExtractTextPlugin = require('extract-text-webpack-plugin');
const path=require('path');

module.exports={
  entry:'./src/index.js',
  output:{
    filename:'bundle.js',
    path:path.resolve(__dirname, 'dist')
  },
  module: {
  rules: [
    {
      test: /\.scss$/,
      use: ExtractTextPlugin.extract({
        fallback: 'style-loader',
        use: ['css-loader', 'sass-loader']
      })
    }
  ]
},
plugins: [
 new ExtractTextPlugin('style.css')
],
resolve: {
    extensions: ['.js', '.scss']
}
}


scss and js files are in the same folder (src).
scss included in input index.js:
import './src/base.scss'
When I run webpack, I get an error:
Module not found: Error: Can't resolve './src/base.scss'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2020-07-13
@MFT

./
this is from the current directory of the file

scss and js files are in the same folder

well, connect them at the same level, otherwise it turns out src/src/base.scss

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question