SCSS file cannot import node_module

Tried @import "~react-icons" in an SCSS file.

I get an error: Module build failed: @import "~react-icons"; ^ File to import not found or unreadable: ~react-icons.

This was an npm module that I installed and is on package-json.

My webpack configuration looks like this:

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

let BUILD_DIR = path.resolve(__dirname, 'dist');
let APP_DIR = path.resolve(__dirname, 'src');

let config = {
    entry: path.join(APP_DIR, '/index.js'),
    output: {
        path: BUILD_DIR,
        filename: 'bundle.js'
    },
    module: {
        rules: [
            {
                test: /\.jsx?/,
                include: APP_DIR,
                loaders: ['babel-loader']
            },
            {
                test: /\.scss$/,
                use: ExtractTextPlugin.extract({
                  fallback: "style-loader",
                  use: ['css-loader', 'sass-loader'],
                  publicPath: "/dist"
                })
            },
            {
                test: /\.(ttf|eot|svg|gif|woff(2)?)(\?[a-z0-9]+)?(\?v=
                     [0-9]\.[0-9]\.[0-9])?$/,
                loader: 'file-loader',
            }
        ]
    },
    resolve: {
        extensions: ['.js', '.jsx']
    },
    devServer: {
        contentBase: path.join(__dirname),
        // serve index.html in place of 404 responses to allow HTML5 
        // history
        historyApiFallback: true
    },
    plugins: [
        new webpack.HotModuleReplacementPlugin(),
        new HtmlWebpackPlugin({
          title: 'Project',
          minify: {
            collapseWhitespace: true
          },
          hash: true,
          template: './index.html'
        }),
        new ExtractTextPlugin({
          filename: 'style.css',
          disable: false,
          allChunks: true
        })
    ]
};

module.exports = config;

0 Comment

NO COMMENTS

LEAVE A REPLY

Captcha image